diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index 5cc1a95..090b883 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -7,8 +7,12 @@ namespace Drupal\Core\Config; +use Drupal\Component\Utility\String; use Drupal\Core\Config\ConfigEvents; +use Drupal\Core\Config\Entity\ConfigStorageControllerInterface; +use Drupal\Core\Config\Entity\ImportableEntityStorageInterface; use Drupal\Core\DependencyInjection\DependencySerialization; +use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Lock\LockBackendInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -292,14 +296,15 @@ protected function importConfig($op, $name) { * @param string $name * The name of the configuration to process. * + * @throws \Drupal\Core\Entity\EntityStorageException + * Thrown if the data is owned by an entity type, but the entity storage + * does not support imports. + * * @return bool * TRUE if the configuration was imported as a configuration entity. FALSE * otherwise. */ protected function importInvokeOwner($op, $name) { - // Call to the configuration entity's storage controller to handle the - // configuration change. - $handled_by_module = FALSE; // Validate the configuration object name before importing it. // Config::validateName($name); if ($entity_type = $this->configManager->getEntityTypeIdByName($name)) { @@ -315,9 +320,13 @@ protected function importInvokeOwner($op, $name) { } $method = 'import' . ucfirst($op); - $handled_by_module = $this->configManager->getEntityManager()->getStorageController($entity_type)->$method($name, $new_config, $old_config); - } - if (!empty($handled_by_module)) { + $entity_storage = $this->configManager->getEntityManager()->getStorageController($entity_type); + // Call to the configuration entity's storage controller to handle the + // configuration change. + if (!($entity_storage instanceof ImportableEntityStorageInterface)) { + throw new EntityStorageException(String::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type))); + } + $entity_storage->$method($name, $new_config, $old_config); $this->setProcessed($op, $name); return TRUE; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 234ad2a..18d986f 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -35,7 +35,7 @@ * after the config_prefix in a config name forms the entity ID. Additional or * custom suffixes are not possible. */ -class ConfigStorageController extends EntityStorageControllerBase implements ConfigStorageControllerInterface { +class ConfigStorageController extends EntityStorageControllerBase implements ConfigStorageControllerInterface, ImportableEntityStorageInterface { /** * The UUID service. diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php index 4ffe876..e479b7f 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php @@ -16,51 +16,6 @@ interface ConfigStorageControllerInterface extends EntityStorageControllerInterface { /** - * Create configuration upon synchronizing configuration changes. - * - * This callback is invoked when configuration is synchronized between storages - * and allows a module to take over the synchronization of configuration data. - * - * @param string $name - * The name of the configuration object. - * @param \Drupal\Core\Config\Config $new_config - * A configuration object containing the new configuration data. - * @param \Drupal\Core\Config\Config $old_config - * A configuration object containing the old configuration data. - */ - public function importCreate($name, Config $new_config, Config $old_config); - - /** - * Updates configuration upon synchronizing configuration changes. - * - * This callback is invoked when configuration is synchronized between storages - * and allows a module to take over the synchronization of configuration data. - * - * @param string $name - * The name of the configuration object. - * @param \Drupal\Core\Config\Config $new_config - * A configuration object containing the new configuration data. - * @param \Drupal\Core\Config\Config $old_config - * A configuration object containing the old configuration data. - */ - public function importUpdate($name, Config $new_config, Config $old_config); - - /** - * Delete configuration upon synchronizing configuration changes. - * - * This callback is invoked when configuration is synchronized between storages - * and allows a module to take over the synchronization of configuration data. - * - * @param string $name - * The name of the configuration object. - * @param \Drupal\Core\Config\Config $new_config - * A configuration object containing the new configuration data. - * @param \Drupal\Core\Config\Config $old_config - * A configuration object containing the old configuration data. - */ - public function importDelete($name, Config $new_config, Config $old_config); - - /** * Returns the config prefix used by the configuration entity type. * * @return string diff --git a/core/lib/Drupal/Core/Config/Entity/ImportableEntityStorageInterface.php b/core/lib/Drupal/Core/Config/Entity/ImportableEntityStorageInterface.php new file mode 100644 index 0000000..6aca4df --- /dev/null +++ b/core/lib/Drupal/Core/Config/Entity/ImportableEntityStorageInterface.php @@ -0,0 +1,56 @@ +