diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index d354799..63ceb1c 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -67,6 +67,8 @@ class Config extends StorableConfigBase { * The typed configuration manager service. */ public function __construct($name, StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config) { + // Validate the configuration object name. + static::validateName($name); $this->name = $name; $this->storage = $storage; $this->eventDispatcher = $event_dispatcher; @@ -204,8 +206,6 @@ public function clear($key) { * {@inheritdoc} */ public function save() { - // Validate the configuration object name before saving. - static::validateName($this->name); // If there is a schema for this configuration object, cast all values to // conform to the schema. diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php index f259dc7..86df1f8 100644 --- a/core/lib/Drupal/Core/Config/ConfigBase.php +++ b/core/lib/Drupal/Core/Config/ConfigBase.php @@ -78,6 +78,8 @@ public function getName() { * The configuration object. */ public function setName($name) { + // Validate the configuration object. + static::validateName($name); $this->name = $name; return $this; } @@ -85,6 +87,11 @@ public function setName($name) { /** * Validates the configuration object name. * + * A valid name must: + * - Be namespaced by its owner (i.e. contain at least one '.'). + * - Be shorter than Config::MAX_NAME_LENGTH characters. + * - Not contain any of the following characters: ? : * < > " ' / \ + * * @param string $name * The name of the configuration object. * @@ -93,7 +100,7 @@ public function setName($name) { * @see Config::MAX_NAME_LENGTH */ public static function validateName($name) { - // The name must be namespaced by owner. + // The name must be namespaced by its owner. if (strpos($name, '.') === FALSE) { throw new ConfigNameException(String::format('Missing namespace in Config object name @name.', array( '@name' => $name,