class ConfigSubscriber
Rebuilds the container when locale config is changed.
Hierarchy
- class \Drupal\locale\EventSubscriber\ConfigSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ConfigSubscriber
File
-
core/
modules/ locale/ src/ EventSubscriber/ ConfigSubscriber.php, line 14
Namespace
Drupal\locale\EventSubscriberView source
class ConfigSubscriber implements EventSubscriberInterface {
public function __construct(#[Autowire(service: 'kernel')] private DrupalKernel $kernel) {
}
/**
* Causes the container to be rebuilt on the next request if necessary.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* The configuration event.
*/
public function onConfigSave(ConfigCrudEvent $event) : void {
$saved_config = $event->getConfig();
if (!$saved_config->isNew() && $saved_config->getName() == 'locale.settings' && $event->isChanged('translate_english')) {
// Trigger a container rebuild on the next request by invalidating it.
$this->kernel
->invalidateContainer();
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
$events[ConfigEvents::SAVE][] = [
'onConfigSave',
0,
];
return $events;
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| ConfigSubscriber::getSubscribedEvents | public static | function | |
| ConfigSubscriber::onConfigSave | public | function | Causes the container to be rebuilt on the next request if necessary. |
| ConfigSubscriber::__construct | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.