Mercurial > hg > isophonics-drupal-site
annotate core/modules/config/src/ConfigSubscriber.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | c2387f117808 |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\config; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Config\ConfigEvents; |
Chris@0 | 6 use Drupal\Core\Config\ConfigImporterEvent; |
Chris@0 | 7 use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase; |
Chris@0 | 8 |
Chris@0 | 9 /** |
Chris@0 | 10 * Config subscriber. |
Chris@0 | 11 */ |
Chris@0 | 12 class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase { |
Chris@0 | 13 |
Chris@0 | 14 /** |
Chris@0 | 15 * Checks that the Configuration module is not being uninstalled. |
Chris@0 | 16 * |
Chris@12 | 17 * @param \Drupal\Core\Config\ConfigImporterEvent $event |
Chris@0 | 18 * The config import event. |
Chris@0 | 19 */ |
Chris@0 | 20 public function onConfigImporterValidate(ConfigImporterEvent $event) { |
Chris@16 | 21 // Make sure config syncs performed via the Config UI don't break, but |
Chris@16 | 22 // don't worry about syncs initiated via the command line. |
Chris@16 | 23 if (PHP_SAPI === 'cli') { |
Chris@16 | 24 return; |
Chris@16 | 25 } |
Chris@0 | 26 $importer = $event->getConfigImporter(); |
Chris@0 | 27 $core_extension = $importer->getStorageComparer()->getSourceStorage()->read('core.extension'); |
Chris@0 | 28 if (!isset($core_extension['module']['config'])) { |
Chris@0 | 29 $importer->logError($this->t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.')); |
Chris@0 | 30 } |
Chris@0 | 31 } |
Chris@0 | 32 |
Chris@0 | 33 /** |
Chris@0 | 34 * {@inheritdoc} |
Chris@0 | 35 */ |
Chris@0 | 36 public static function getSubscribedEvents() { |
Chris@0 | 37 $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20]; |
Chris@0 | 38 return $events; |
Chris@0 | 39 } |
Chris@0 | 40 |
Chris@0 | 41 } |