Mercurial > hg > isophonics-drupal-site
diff core/modules/config/src/ConfigSubscriber.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/config/src/ConfigSubscriber.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,36 @@ +<?php + +namespace Drupal\config; + +use Drupal\Core\Config\ConfigEvents; +use Drupal\Core\Config\ConfigImporterEvent; +use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase; + +/** + * Config subscriber. + */ +class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase { + + /** + * Checks that the Configuration module is not being uninstalled. + * + * @param ConfigImporterEvent $event + * The config import event. + */ + public function onConfigImporterValidate(ConfigImporterEvent $event) { + $importer = $event->getConfigImporter(); + $core_extension = $importer->getStorageComparer()->getSourceStorage()->read('core.extension'); + if (!isset($core_extension['module']['config'])) { + $importer->logError($this->t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.')); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20]; + return $events; + } + +}