diff --git a/core/lib/Drupal/Core/Config/Schema/Element.php b/core/lib/Drupal/Core/Config/Schema/Element.php index 2563ec5..21309bf 100644 --- a/core/lib/Drupal/Core/Config/Schema/Element.php +++ b/core/lib/Drupal/Core/Config/Schema/Element.php @@ -22,10 +22,35 @@ protected $value; /** + * The parent element object. + * + * @var Element + */ + protected $parent; + + /** * Create typed config object. */ protected function parseElement($key, $data, $definition) { return \Drupal::service('config.typed')->create($definition, $data, $key, $this); } + /** + * Get the full config path of the element. + * + * @return string + * The full config path of the element starting with the top element key + * followed by a colon followed by element names separated with dots. + * For example: views.view.content:display.default.display_options. + */ + protected function getFullName() { + if (isset($this->parent)) { + // Ensure if the parent was the root element, we do not add a dot after. + return str_replace(':.', ':', $this->parent->getFullName() . '.' . $this->getName()); + } + else { + // If there is no parent, this is the root element, add a colon. + return $this->getName() . ':'; + } + } } diff --git a/core/lib/Drupal/Core/Config/Schema/Mapping.php b/core/lib/Drupal/Core/Config/Schema/Mapping.php index 19fb596..5554e1f 100644 --- a/core/lib/Drupal/Core/Config/Schema/Mapping.php +++ b/core/lib/Drupal/Core/Config/Schema/Mapping.php @@ -37,6 +37,10 @@ protected function parse() { * * Since all configuration objects are mappings the function will except a dot * delimited key to access nested values, for example, 'page.front'. + * + * @throws \Drupal\Core\Config\Schema\SchemaIncompleteException + * If a property is requested that does not have schema or does not exist in + * the data. */ public function get($property_name) { $parts = explode('.', $property_name); @@ -46,13 +50,13 @@ public function get($property_name) { $element = $elements[$root_key]; } else { - throw new SchemaIncompleteException(String::format("The configuration property @key doesn't exist.", array('@key' => $property_name))); + throw new SchemaIncompleteException(String::format("@key.@element does not exist or does not have schema defined.", array('@key' => $this->getFullName(), '@element' => $property_name))); } // If $property_name contained a dot recurse into the keys. foreach ($parts as $key) { if (!is_object($element) || !method_exists($element, 'get')) { - throw new SchemaIncompleteException(String::format("The configuration property @key does not exist.", array('@key' => $property_name))); + throw new SchemaIncompleteException(String::format("@key.@element does not exist or does not have schema defined.", array('@key' => $this->getFullName(), '@element' => $property_name))); } $element = $element->get($key); } diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php index 9c0fba8..f4fe968 100644 --- a/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\String; use Drupal\Core\Config\Schema\Ignore; -use Drupal\Core\Config\Schema\SchemaIncompleteException; use Drupal\Core\TypedData\PrimitiveInterface; use Drupal\Core\TypedData\Type\FloatInterface; use Drupal\Core\TypedData\Type\IntegerInterface; @@ -128,7 +127,7 @@ public function getStorage() { protected function getSchemaWrapper() { if (!isset($this->schemaWrapper)) { $definition = $this->typedConfigManager->getDefinition($this->name); - $this->schemaWrapper = $this->typedConfigManager->create($definition, $this->data); + $this->schemaWrapper = $this->typedConfigManager->create($definition, $this->data, $this->name); } return $this->schemaWrapper; } @@ -169,16 +168,7 @@ protected function validateValue($key, $value) { * Exception on unsupported/undefined data type deducted. */ protected function castValue($key, $value) { - $element = FALSE; - try { - $element = $this->getSchemaWrapper()->get($key); - } - catch (SchemaIncompleteException $e) { - // @todo Consider making schema handling more strict by throwing - // SchemaIncompleteException for all incomplete schema conditions *and* - // throwing it forward. See https://drupal.org/node/2183983. - // Until then, we need to handle the Undefined case below. - } + $element = $this->getSchemaWrapper()->get($key); // Do not cast value if it is unknown or defined to be ignored. if ($element && ($element instanceof Undefined || $element instanceof Ignore)) { return $value; diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index 3594907..534fc0e 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -81,7 +81,7 @@ public function __construct(StorageInterface $configStorage, StorageInterface $s public function get($name) { $data = $this->configStorage->read($name); $definition = $this->getDefinition($name); - return $this->create($definition, $data); + return $this->create($definition, $data, $name); } /** diff --git a/core/modules/block/custom_block/config/schema/custom_block.schema.yml b/core/modules/block/custom_block/config/schema/custom_block.schema.yml index 1a9c04d..9c1c4e3 100644 --- a/core/modules/block/custom_block/config/schema/custom_block.schema.yml +++ b/core/modules/block/custom_block/config/schema/custom_block.schema.yml @@ -22,6 +22,9 @@ custom_block.type.*: status: type: boolean label: 'Status' + dependencies: + type: config_dependencies + label: 'Dependencies' langcode: type: string label: 'Default language' diff --git a/core/modules/config/src/Tests/ConfigSchemaTestBase.php b/core/modules/config/src/Tests/ConfigSchemaTestBase.php index eac1a75..1b737f4 100644 --- a/core/modules/config/src/Tests/ConfigSchemaTestBase.php +++ b/core/modules/config/src/Tests/ConfigSchemaTestBase.php @@ -61,7 +61,7 @@ public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $c return; } $definition = $typed_config->getDefinition($config_name); - $this->schema = $typed_config->create($definition, $config_data); + $this->schema = $typed_config->create($definition, $config_data, $config_name); $this->configPass = TRUE; foreach ($config_data as $key => $value) { $this->checkValue($key, $value); diff --git a/core/modules/contact/config/schema/contact.schema.yml b/core/modules/contact/config/schema/contact.schema.yml index c853697..4bac845 100644 --- a/core/modules/contact/config/schema/contact.schema.yml +++ b/core/modules/contact/config/schema/contact.schema.yml @@ -28,6 +28,9 @@ contact.category.*: status: type: boolean label: 'Status' + dependencies: + type: config_dependencies + label: 'Dependencies' langcode: type: string label: 'Default language' diff --git a/core/modules/filter/config/schema/filter.schema.yml b/core/modules/filter/config/schema/filter.schema.yml index f1df7df..2e8dd3f 100644 --- a/core/modules/filter/config/schema/filter.schema.yml +++ b/core/modules/filter/config/schema/filter.schema.yml @@ -44,6 +44,9 @@ filter.format.*: label: 'Enabled filters' sequence: - type: filter + dependencies: + type: config_dependencies + label: 'Dependencies' langcode: type: string label: 'Default language' diff --git a/core/modules/image/config/schema/image.schema.yml b/core/modules/image/config/schema/image.schema.yml index 5b642b3..d0c77e6 100644 --- a/core/modules/image/config/schema/image.schema.yml +++ b/core/modules/image/config/schema/image.schema.yml @@ -24,6 +24,9 @@ image.style.*: type: integer uuid: type: string + dependencies: + type: config_dependencies + label: 'Dependencies' langcode: type: string label: 'Default language' diff --git a/core/modules/menu_ui/config/schema/menu_ui.schema.yml b/core/modules/menu_ui/config/schema/menu_ui.schema.yml index ce6be8b..aef46b8 100644 --- a/core/modules/menu_ui/config/schema/menu_ui.schema.yml +++ b/core/modules/menu_ui/config/schema/menu_ui.schema.yml @@ -24,3 +24,6 @@ menu.entity.node.*: sequence: - type: string label: 'Menu machine name' + parent: + type: string + label: 'Parent' diff --git a/core/modules/shortcut/config/schema/shortcut.schema.yml b/core/modules/shortcut/config/schema/shortcut.schema.yml index 81192bc..ac96296 100644 --- a/core/modules/shortcut/config/schema/shortcut.schema.yml +++ b/core/modules/shortcut/config/schema/shortcut.schema.yml @@ -25,3 +25,6 @@ shortcut.set.*: status: type: boolean label: 'Status' + dependencies: + type: config_dependencies + label: 'Dependencies' diff --git a/core/modules/system/config/schema/system.schema.yml b/core/modules/system/config/schema/system.schema.yml index 690a3ec..27e1a39 100644 --- a/core/modules/system/config/schema/system.schema.yml +++ b/core/modules/system/config/schema/system.schema.yml @@ -130,6 +130,9 @@ system.date_format.*: status: type: boolean label: 'Enabled' + dependencies: + type: config_dependencies + label: 'Dependencies' locked: type: boolean label: 'Locked' @@ -297,6 +300,9 @@ system.menu.*: langcode: type: string label: 'Default language' + dependencies: + type: config_dependencies + label: 'Dependencies' locked: type: boolean label: '' diff --git a/core/modules/user/config/schema/user.schema.yml b/core/modules/user/config/schema/user.schema.yml index 7361704..5c921fc 100644 --- a/core/modules/user/config/schema/user.schema.yml +++ b/core/modules/user/config/schema/user.schema.yml @@ -140,6 +140,9 @@ user.role.*: status: type: boolean label: 'Status' + dependencies: + type: config_dependencies + label: 'Dependencies' langcode: type: string label: 'Default language'