You are here

public function LazyContextRepository::getAvailableContexts in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/LazyContextRepository.php \Drupal\Core\Plugin\Context\LazyContextRepository::getAvailableContexts()

Gets all available contexts for the purposes of configuration.

Return value

\Drupal\Core\Plugin\Context\ContextInterface[] All available contexts.

Overrides ContextRepositoryInterface::getAvailableContexts

File

core/lib/Drupal/Core/Plugin/Context/LazyContextRepository.php, line 94

Class

LazyContextRepository
Provides a context repository which uses context provider services.

Namespace

Drupal\Core\Plugin\Context

Code

public function getAvailableContexts() {
  $contexts = [];
  foreach ($this->contextProviderServiceIDs as $service_id) {
    $contexts_by_service = $this->container
      ->get($service_id)
      ->getAvailableContexts();
    foreach ($contexts_by_service as $unqualified_context_id => $context) {
      $context_id = '@' . $service_id . ':' . $unqualified_context_id;
      $contexts[$context_id] = $context;
    }
  }
  return $contexts;
}