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