3 namespace Drupal\serialization\EventSubscriber;
5 use Drupal\Core\Config\ConfigCrudEvent;
6 use Drupal\Core\Config\ConfigEvents;
7 use Drupal\Core\DrupalKernelInterface;
8 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
11 * Config event subscriber to rebuild the container when BC config is saved.
13 class BcConfigSubscriber implements EventSubscriberInterface {
18 * @var \Drupal\Core\DrupalKernelInterface
23 * BcConfigSubscriber constructor.
25 * @param \Drupal\Core\DrupalKernelInterface $kernel
28 public function __construct(DrupalKernelInterface $kernel) {
29 $this->kernel = $kernel;
35 public static function getSubscribedEvents() {
36 $events[ConfigEvents::SAVE][] = 'onConfigSave';
41 * Invalidates the service container if serialization BC config gets updated.
43 * @param \Drupal\Core\Config\ConfigCrudEvent $event
45 public function onConfigSave(ConfigCrudEvent $event) {
46 $saved_config = $event->getConfig();
48 if ($saved_config->getName() === 'serialization.settings') {
49 if ($event->isChanged('bc_primitives_as_strings')) {
50 $this->kernel->invalidateContainer();