Mercurial > hg > isophonics-drupal-site
annotate core/modules/serialization/src/EventSubscriber/BcConfigSubscriber.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\serialization\EventSubscriber; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Config\ConfigCrudEvent; |
Chris@0 | 6 use Drupal\Core\Config\ConfigEvents; |
Chris@0 | 7 use Drupal\Core\DrupalKernelInterface; |
Chris@0 | 8 use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
Chris@0 | 9 |
Chris@0 | 10 /** |
Chris@0 | 11 * Config event subscriber to rebuild the container when BC config is saved. |
Chris@0 | 12 */ |
Chris@0 | 13 class BcConfigSubscriber implements EventSubscriberInterface { |
Chris@0 | 14 |
Chris@0 | 15 /** |
Chris@0 | 16 * The Drupal Kernel. |
Chris@0 | 17 * |
Chris@0 | 18 * @var \Drupal\Core\DrupalKernelInterface |
Chris@0 | 19 */ |
Chris@0 | 20 protected $kernel; |
Chris@0 | 21 |
Chris@0 | 22 /** |
Chris@0 | 23 * BcConfigSubscriber constructor. |
Chris@0 | 24 * |
Chris@0 | 25 * @param \Drupal\Core\DrupalKernelInterface $kernel |
Chris@0 | 26 * The Drupal Kernel. |
Chris@0 | 27 */ |
Chris@0 | 28 public function __construct(DrupalKernelInterface $kernel) { |
Chris@0 | 29 $this->kernel = $kernel; |
Chris@0 | 30 } |
Chris@0 | 31 |
Chris@0 | 32 /** |
Chris@0 | 33 * {@inheritdoc} |
Chris@0 | 34 */ |
Chris@0 | 35 public static function getSubscribedEvents() { |
Chris@0 | 36 $events[ConfigEvents::SAVE][] = 'onConfigSave'; |
Chris@0 | 37 return $events; |
Chris@0 | 38 } |
Chris@0 | 39 |
Chris@0 | 40 /** |
Chris@0 | 41 * Invalidates the service container if serialization BC config gets updated. |
Chris@0 | 42 * |
Chris@0 | 43 * @param \Drupal\Core\Config\ConfigCrudEvent $event |
Chris@0 | 44 */ |
Chris@0 | 45 public function onConfigSave(ConfigCrudEvent $event) { |
Chris@0 | 46 $saved_config = $event->getConfig(); |
Chris@0 | 47 |
Chris@0 | 48 if ($saved_config->getName() === 'serialization.settings') { |
Chris@0 | 49 if ($event->isChanged('bc_primitives_as_strings') || $event->isChanged('bc_timestamp_normalizer_unix')) { |
Chris@0 | 50 $this->kernel->invalidateContainer(); |
Chris@0 | 51 } |
Chris@0 | 52 } |
Chris@0 | 53 } |
Chris@0 | 54 |
Chris@0 | 55 } |