Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/config/src/ConfigSubscriber.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
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 // 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') { | |
24 return; | |
25 } | |
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.')); | |
30 } | |
31 } | |
32 | |
33 /** | |
34 * {@inheritdoc} | |
35 */ | |
36 public static function getSubscribedEvents() { | |
37 $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20]; | |
38 return $events; | |
39 } | |
40 | |
41 } |