Version 1
[yaffs-website] / web / core / modules / config / src / ConfigSubscriber.php
1 <?php
2
3 namespace Drupal\config;
4
5 use Drupal\Core\Config\ConfigEvents;
6 use Drupal\Core\Config\ConfigImporterEvent;
7 use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase;
8
9
10 /**
11  * Config subscriber.
12  */
13 class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase {
14
15   /**
16    * Checks that the Configuration module is not being uninstalled.
17    *
18    * @param ConfigImporterEvent $event
19    *   The config import event.
20    */
21   public function onConfigImporterValidate(ConfigImporterEvent $event) {
22     $importer = $event->getConfigImporter();
23     $core_extension = $importer->getStorageComparer()->getSourceStorage()->read('core.extension');
24     if (!isset($core_extension['module']['config'])) {
25       $importer->logError($this->t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'));
26     }
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public static function getSubscribedEvents() {
33     $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20];
34     return $events;
35   }
36
37 }