final class Generic in Core Context 8
Exposes contexts from various provider services, under a single namespace.
Hierarchy
- class \Drupal\core_context\ContextProvider\Generic implements ContextProviderInterface
Expanded class hierarchy of Generic
1 string reference to 'Generic'
1 service uses Generic
File
- src/
ContextProvider/ Generic.php, line 10
Namespace
Drupal\core_context\ContextProviderView source
final class Generic implements ContextProviderInterface {
/**
* The provider services from which to expose contexts.
*
* @var \Drupal\Core\Plugin\Context\ContextProviderInterface[]
*/
private $providers = [];
/**
* Adds a provider service from which to expose contexts.
*
* @param \Drupal\Core\Plugin\Context\ContextProviderInterface $provider
* The context provider to add.
*/
public function addProvider(ContextProviderInterface $provider) {
array_push($this->providers, $provider);
}
/**
* {@inheritdoc}
*/
public function getRuntimeContexts(array $unqualified_context_ids) {
$contexts = [];
foreach ($this->providers as $provider) {
$contexts = array_merge($contexts, $provider
->getRuntimeContexts($unqualified_context_ids));
}
return $contexts;
}
/**
* {@inheritdoc}
*/
public function getAvailableContexts() {
$contexts = [];
foreach ($this->providers as $provider) {
$contexts = array_merge($contexts, $provider
->getAvailableContexts());
}
return $contexts;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Generic:: |
private | property | The provider services from which to expose contexts. | |
Generic:: |
public | function | Adds a provider service from which to expose contexts. | |
Generic:: |
public | function |
Gets all available contexts for the purposes of configuration. Overrides ContextProviderInterface:: |
|
Generic:: |
public | function |
Gets runtime context values for the given context IDs. Overrides ContextProviderInterface:: |