3 namespace Drupal\config;
5 use Drupal\Core\Config\ConfigEvents;
6 use Drupal\Core\Config\ConfigImporterEvent;
7 use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase;
12 class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase {
15 * Checks that the Configuration module is not being uninstalled.
17 * @param \Drupal\Core\Config\ConfigImporterEvent $event
18 * The config import event.
20 public function onConfigImporterValidate(ConfigImporterEvent $event) {
21 // Make sure config syncs performed via the Config UI don't break, but
22 // don't worry about syncs initiated via the command line.
23 if (PHP_SAPI === 'cli') {
26 $importer = $event->getConfigImporter();
27 $core_extension = $importer->getStorageComparer()->getSourceStorage()->read('core.extension');
28 if (!isset($core_extension['module']['config'])) {
29 $importer->logError($this->t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'));
36 public static function getSubscribedEvents() {
37 $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20];