You are here

protected function LayoutBuilderContextTrait::getAvailableContexts in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Context/LayoutBuilderContextTrait.php \Drupal\layout_builder\Context\LayoutBuilderContextTrait::getAvailableContexts()

Provides all available contexts, both global and section_storage-specific.

Parameters

\Drupal\layout_builder\SectionStorageInterface $section_storage: The section storage.

Return value

\Drupal\Core\Plugin\Context\ContextInterface[] The array of context objects.

4 calls to LayoutBuilderContextTrait::getAvailableContexts()
ChooseBlockController::build in core/modules/layout_builder/src/Controller/ChooseBlockController.php
Provides the UI for choosing a new block.
ChooseBlockController::inlineBlockList in core/modules/layout_builder/src/Controller/ChooseBlockController.php
Provides the UI for choosing a new inline block.
ConfigureBlockFormBase::doBuildForm in core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php
Builds the form for the block.
LayoutBuilder::buildAdministrativeSection in core/modules/layout_builder/src/Element/LayoutBuilder.php
Builds the render array for the layout section while editing.

File

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

Class

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

Namespace

Drupal\layout_builder\Context

Code

protected function getAvailableContexts(SectionStorageInterface $section_storage) {

  // Get all globally available contexts that have a defined value.
  $contexts = array_filter($this
    ->contextRepository()
    ->getAvailableContexts(), function (ContextInterface $context) {
    return $context
      ->hasContextValue();
  });

  // Add in the per-section_storage contexts.
  $contexts += $section_storage
    ->getContextsDuringPreview();
  return $contexts;
}