BcConfigSubscriber.php in Drupal 8
File
core/modules/serialization/src/EventSubscriber/BcConfigSubscriber.php
View source
<?php
namespace Drupal\serialization\EventSubscriber;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\DrupalKernelInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class BcConfigSubscriber implements EventSubscriberInterface {
protected $kernel;
public function __construct(DrupalKernelInterface $kernel) {
$this->kernel = $kernel;
}
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = 'onConfigSave';
return $events;
}
public function onConfigSave(ConfigCrudEvent $event) {
$saved_config = $event
->getConfig();
if ($saved_config
->getName() === 'serialization.settings') {
if ($event
->isChanged('bc_primitives_as_strings') || $event
->isChanged('bc_timestamp_normalizer_unix')) {
$this->kernel
->invalidateContainer();
}
}
}
}