function LayoutBuilderContextTrait::contextRepository

Same name in other branches
  1. 9 core/modules/layout_builder/src/Context/LayoutBuilderContextTrait.php \Drupal\layout_builder\Context\LayoutBuilderContextTrait::contextRepository()
  2. 8.9.x core/modules/layout_builder/src/Context/LayoutBuilderContextTrait.php \Drupal\layout_builder\Context\LayoutBuilderContextTrait::contextRepository()
  3. 10 core/modules/layout_builder/src/Context/LayoutBuilderContextTrait.php \Drupal\layout_builder\Context\LayoutBuilderContextTrait::contextRepository()

Gets the context repository service.

Return value

\Drupal\Core\Plugin\Context\ContextRepositoryInterface The context repository service.

File

core/modules/layout_builder/src/Context/LayoutBuilderContextTrait.php, line 26

Class

LayoutBuilderContextTrait
Provides a wrapper around getting contexts from a section storage object.

Namespace

Drupal\layout_builder\Context

Code

protected function contextRepository() {
    if (!$this->contextRepository) {
        $this->contextRepository = \Drupal::service('context.repository');
    }
    return $this->contextRepository;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.