diff --git a/core/includes/config.inc b/core/includes/config.inc index b92c741..0444a91 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -1,7 +1,7 @@ delete($name); } @@ -186,8 +181,6 @@ function config_import() { * @param Drupal\Core\Config\StorageInterface $target_storage * The storage to synchronize configuration to. * - * @throws Drupal\Core\Config\ConfigException - * * @todo Add support for other extension types; e.g., themes etc. */ function config_import_invoke_owner(array $config_changes, StorageInterface $source_storage, StorageInterface $target_storage) { @@ -197,10 +190,7 @@ function config_import_invoke_owner(array $config_changes, StorageInterface $sou // handle dependencies correctly. foreach (array('delete', 'create', 'change') as $op) { foreach ($config_changes[$op] as $key => $name) { - // Bail out if the configuration object is not namespaced by extension. - if (strpos($name, '.') === FALSE) { - throw new ConfigException(sprintf('Missing namespace in Config name %s', $name)); - } + Config::checkNamespace($name); // Extract owner from configuration object name. $module = strtok($name, '.'); // Check whether the module implements hook_config_import() and ask it to diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 4f1474d..6991030 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Config; +use Drupal\Core\Config\ConfigException; use Drupal\Component\Utility\NestedArray; /** @@ -289,14 +290,11 @@ class Config { /** * Saves the configuration object. * - * @throws Drupal\Core\Config\ConfigException */ public function save() { // All configuration objects need to be namespaced by extension, as it would // be impossible to maintain them otherwise. - if (strpos($this->name, '.') === FALSE) { - throw new ConfigException(sprintf('Missing namespace in Config name %s', $this->name)); - } + $this->checkNamespace($this->name); $this->sortByKey($this->data); $this->storage->write($this->name, $this->data); $this->isNew = FALSE; @@ -333,4 +331,15 @@ class Config { $this->resetOverriddenData(); return $this; } + /** + * Checks if a configuration object is namespaced by extension. + * + * @throws Drupal\Core\Config\ConfigException + */ + public static function checkNamespace($name) + { + if (strpos($name, '.') === FALSE) { + throw new ConfigException(format_string('Missing namespace in Config name @name', array('@name' => $name))); + } + } }