Defines configuration context factory.
The configuration context factory creates configuration context objects.
Expanded class hierarchy of ConfigContextFactory
\Drupal\Core\Config\Context\ContextInterface
class ConfigContextFactory {
/**
* An event dispatcher instance to use for configuration events.
*
* @var \Symfony\Component\EventDispatcher\EventDispatcher
*/
protected $eventDispatcher;
/**
* Constructs the configuration context.
*
* @param \Symfony\Component\EventDispatcher\EventDispatcher $event_dispatcher
* An event dispatcher instance to use for configuration events.
*/
public function __construct(EventDispatcher $event_dispatcher) {
$this->eventDispatcher = $event_dispatcher;
}
/**
* Returns a configuration context object.
*
* @param string $class
* (Optional) The name of the configuration class to use. Defaults to
* Drupal\Core\Config\Context\ConfigContext
*
* @return \Drupal\Core\Config\Context\ContextInterface $context
* (Optional) The configuration context to use.
*/
public function get($class = NULL) {
if (!$class) {
$class = 'Drupal\\Core\\Config\\Context\\ConfigContext';
}
if (class_exists($class)) {
$context = new $class($this->eventDispatcher);
}
else {
throw new ConfigException(sprintf('Unknown config context class: %s', $class));
}
return $context;
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigContextFactory:: |
protected | property | An event dispatcher instance to use for configuration events. | |
ConfigContextFactory:: |
public | function | Returns a configuration context object. | |
ConfigContextFactory:: |
public | function | Constructs the configuration context. |