diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 68502c6..646aea3 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -56,6 +56,13 @@ class Config { protected $name; /** + * The schema-applicable name of the configuration object. + * + * @var string + */ + protected $schemaName; + + /** * Whether the configuration object is new or has been saved to the storage. * * @var bool @@ -137,7 +144,7 @@ class Config { * The language object used to override configuration data. */ public function __construct($name, StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManager $typed_config, Language $language = NULL) { - $this->name = $name; + $this->setName($name); $this->storage = $storage; $this->eventDispatcher = $event_dispatcher; $this->typedConfigManager = $typed_config; @@ -183,7 +190,12 @@ public function getName() { * The configuration object. */ public function setName($name) { - $this->name = $name; + $this->name = $this->schemaName = $name; + // @todo figure out how to allow expandibility. + $optional_prefixes = array(ConfigFactoryInterface::LANGUAGE_CONFIG_PREFIX); + foreach ($optional_prefixes as $prefix) { + $this->schemaName = preg_replace('!^'. preg_quote($prefix, '!') . '(.+)!', '\1', $name); + } return $this; } @@ -447,7 +459,7 @@ public function save() { // If there is a schema for this configuration object, cast all values to // conform to the schema. - if ($this->typedConfigManager->hasConfigSchema($this->name)) { + if ($this->typedConfigManager->hasConfigSchema($this->schemaName)) { // Ensure that the schema wrapper has the latest data. $this->schemaWrapper = NULL; foreach ($this->data as $key => $value) { @@ -525,7 +537,7 @@ public function merge(array $data_to_merge) { */ protected function getSchemaWrapper() { if (!isset($this->schemaWrapper)) { - $definition = $this->typedConfigManager->getDefinition($this->name); + $definition = $this->typedConfigManager->getDefinition($this->schemaName); $this->schemaWrapper = $this->typedConfigManager->create($definition, $this->data); } return $this->schemaWrapper;