diff --git a/core/lib/Drupal/Core/Config/ConfigEvents.php b/core/lib/Drupal/Core/Config/ConfigEvents.php index dd4c17f..f49b56e 100644 --- a/core/lib/Drupal/Core/Config/ConfigEvents.php +++ b/core/lib/Drupal/Core/Config/ConfigEvents.php @@ -47,7 +47,7 @@ class ConfigEvents { * @see \Drupal\Core\Config\ConfigImporter::validate(). * @see \Drupal\Core\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate(). */ - const VALIDATE = 'config.importer.validate'; + const IMPORT_VALIDATE = 'config.importer.validate'; /** * Name of event fired when when importing configuration to target storage. diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index d159034..8bbc7a4 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Config; +use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Lock\LockBackendInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -20,7 +21,7 @@ * * The ConfigImporter has a identifier which is used to construct event names. * The events fired during an import are: - * - ConfigEvents::VALIDATE: Events listening can throw a + * - ConfigEvents::IMPORT_VALIDATE: Events listening can throw a * \Drupal\Core\Config\ConfigImporterException to prevent an import from * occurring. * @see \Drupal\Core\EventSubscriber\ConfigImportSubscriber @@ -32,9 +33,9 @@ class ConfigImporter { /** - * The name used to identify events and the lock. + * The name used to identify the lock. */ - const ID = 'config.importer'; + const LOCKID = 'config_importer'; /** * The storage comparer used to discover configuration changes. @@ -200,17 +201,18 @@ public function import() { // Ensure that the changes have been validated. $this->validate(); - if (!$this->lock->acquire(static::ID)) { + if (!$this->lock->acquire(static::LOCKID)) { // Another process is synchronizing configuration. - throw new ConfigImporterException(sprintf('%s is already importing', static::ID)); + throw new ConfigImporterException(sprintf('%s is already importing', static::LOCKID)); } $this->importInvokeOwner(); $this->importConfig(); // Allow modules to react to a import. - $this->notify('import'); + $this->eventDispatcher->dispatch(ConfigEvents::IMPORT, new ConfigImporterEvent($this)); + // The import is now complete. - $this->lock->release(static::ID); + $this->lock->release(static::LOCKID); $this->reset(); } return $this; @@ -227,7 +229,7 @@ public function validate() { if (!$this->storageComparer->validateSiteUuid()) { throw new ConfigImporterException('Site UUID in source storage does not match the target storage.'); } - $this->notify('validate'); + $this->eventDispatcher->dispatch(ConfigEvents::IMPORT_VALIDATE, new ConfigImporterEvent($this)); $this->validated = TRUE; } return $this; @@ -294,33 +296,23 @@ protected function importInvokeOwner() { } /** - * Dispatches a config importer event. - * - * @param string $event_name - * The name of the config importer event to dispatch. - */ - protected function notify($event_name) { - $this->eventDispatcher->dispatch(static::ID . '.' . $event_name, new ConfigImporterEvent($this)); - } - - /** * Determines if a import is already running. * * @return bool * TRUE if an import is already running, FALSE if not. */ public function alreadyImporting() { - return !$this->lock->lockMayBeAvailable(static::ID); + return !$this->lock->lockMayBeAvailable(static::LOCKID); } /** - * Returns the identifier for events and locks. + * Returns the lock identifier. * * @return string - * The identifier for events and locks. + * The identifier for locks. */ - public function getId() { - return static::ID; + public function getLockId() { + return static::LOCKID; } } diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php index 16267f4..75f06d4 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -41,7 +41,7 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) { * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[ConfigEvents::VALIDATE][] = array('onConfigImporterValidate', 40); + $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidate', 40); return $events; } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index e495602..d6f5ecb 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -101,7 +101,7 @@ function testImportLock() { $this->assertNoText(t('There are no configuration changes.')); // Acquire a fake-lock on the import mechanism. - $config_importer_lock = $this->configImporter()->getId(); + $config_importer_lock = $this->configImporter()->getLockId(); $this->container->get('lock')->acquire($config_importer_lock); // Attempt to import configuration and verify that an error message appears. diff --git a/core/modules/system/lib/Drupal/system/SystemConfigSubscriber.php b/core/modules/system/lib/Drupal/system/SystemConfigSubscriber.php index 4abc714..39f7b52 100644 --- a/core/modules/system/lib/Drupal/system/SystemConfigSubscriber.php +++ b/core/modules/system/lib/Drupal/system/SystemConfigSubscriber.php @@ -22,7 +22,7 @@ class SystemConfigSubscriber implements EventSubscriberInterface { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::VALIDATE][] = array('onConfigImporterValidate', 20); + $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidate', 20); return $events; } @@ -42,4 +42,3 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) { } } } -