diff -u b/core/modules/config/tests/config_schema_test/config/schema/config_schema_test.schema.yml b/core/modules/config/tests/config_schema_test/config/schema/config_schema_test.schema.yml --- b/core/modules/config/tests/config_schema_test/config/schema/config_schema_test.schema.yml +++ b/core/modules/config/tests/config_schema_test/config/schema/config_schema_test.schema.yml @@ -16 +16 @@ - label: 'Is it wonderful?' \ No newline at end of file + label: 'Is it wonderful?' only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php +++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php @@ -12,6 +12,7 @@ use \Countable; use \IteratorAggregate; use \Traversable; +use Drupal\Component\Utility\String; /** * Defines a generic configuration element that contains multiple properties. @@ -114,4 +115,40 @@ public function getIterator() { return new ArrayIterator($this->getElements()); } + /** + * Returns the schema element for the specified key. + * + * All configuration objects at their root are either of the type + * sequence or mapping which both extend ArrayElement. Enable traversal of the + * schema by excepting a dot delimited key to access nested values, for + * example, 'page.front'. + * + * This implements the get() method on the follow schema classes: + * - \Drupal\Core\Config\Schema\Mapping + * - \Drupal\Core\Config\Schema\Sequence + * To conform with the respective interfaces: + * - \Drupal\Core\TypedData\ComplexDataInterface + * - \Drupal\Core\TypedData\ListInterface + */ + public function get($property_name) { + $parts = explode('.', $property_name); + $root_key = array_shift($parts); + $elements = $this->getElements(); + if (isset($elements[$root_key])) { + $element = $elements[$root_key]; + } + else { + throw new SchemaIncompleteException(String::format("The configuration property @key doesn't exist.", array('@key' => $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))); + } + $element = $element->get($key); + } + return $element; + } + } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/Schema/Mapping.php +++ b/core/lib/Drupal/Core/Config/Schema/Mapping.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Config\Schema; use Drupal\Core\TypedData\ComplexDataInterface; -use Drupal\Component\Utility\String; /** * Defines a mapping configuration element. @@ -33,33 +32,6 @@ protected function parse() { } /** - * Implements Drupal\Core\TypedData\ComplexDataInterface::get(). - * - * Since all configuration objects are mappings the function will except a dot - * delimited key to access nested values, for example, 'page.front'. - */ - public function get($property_name) { - $parts = explode('.', $property_name); - $root_key = array_shift($parts); - $elements = $this->getElements(); - if (isset($elements[$root_key])) { - $element = $elements[$root_key]; - } - else { - throw new SchemaIncompleteException(String::format("The configuration property @key doesn't exist.", array('@key' => $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))); - } - $element = $element->get($key); - } - return $element; - } - - /** * Implements Drupal\Core\TypedData\ComplexDataInterface::set(). */ public function set($property_name, $value, $notify = TRUE) { only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/Schema/Sequence.php +++ b/core/lib/Drupal/Core/Config/Schema/Sequence.php @@ -53,14 +53,6 @@ public function onChange($delta) { /** * {@inheritdoc} */ - public function get($key) { - $elements = $this->getElements(); - return $elements[$key]; - } - - /** - * {@inheritdoc} - */ public function first() { return $this->get(0); }