diff --git a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php index 616f2f9..2b22271 100644 --- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php +++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php @@ -122,6 +122,18 @@ public function getIterator() { } /** + * @inheritdoc + */ + public function getTypedConfigManager() { + if ($this->typedDataManager instanceof TypedConfigManagerInterface) { + return $this->typedDataManager; + } + else { + return \Drupal::service('config.typed'); + } + } + + /** * Creates a contained typed configuration object. * * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition @@ -153,7 +165,7 @@ protected function createElement($definition, $value, $key) { * @return \Drupal\Core\TypedData\DataDefinitionInterface */ protected function buildDataDefinition($definition, $value, $key) { - return $this->getTypedDataManager()->buildDataDefinition($definition, $value, $key, $this); + return $this->getTypedConfigManager()->buildDataDefinition($definition, $value, $key, $this); } } diff --git a/core/lib/Drupal/Core/Config/Schema/Element.php b/core/lib/Drupal/Core/Config/Schema/Element.php index 54a4882..e803dfd 100644 --- a/core/lib/Drupal/Core/Config/Schema/Element.php +++ b/core/lib/Drupal/Core/Config/Schema/Element.php @@ -22,41 +22,4 @@ */ protected $value; - /** - * Gets the typed configuration manager. - * - * Overrides \Drupal\Core\TypedData\TypedDataTrait::getTypedDataManager() to - * ensure the typed configuration manager is returned. - * - * @return \Drupal\Core\Config\TypedConfigManagerInterface - * The typed configuration manager. - */ - public function getTypedDataManager() { - if (empty($this->typedDataManager)) { - $this->setTypedDataManager(\Drupal::service('config.typed')); - } - - return $this->typedDataManager; - } - - /** - * Sets the typed config manager. - * - * Overrides \Drupal\Core\TypedData\TypedDataTrait::setTypedDataManager() to - * ensure that only typed configuration manager can be used. - * - * @param \Drupal\Core\TypedData\TypedDataManagerInterface $typed_data_manager - * The typed config manager. This must be an instance of - * \Drupal\Core\Config\TypedConfigManagerInterface. If it is not, then this - * method will error when assertions are enabled. We can not narrow the - * typehint as this will cause PHP errors. - * - * @return $this - */ - public function setTypedDataManager(TypedDataManagerInterface $typed_data_manager) { - assert('$typed_data_manager instanceof \Drupal\Core\Config\TypedConfigManagerInterface'); - $this->typedDataManager = $typed_data_manager; - return $this; - } - } diff --git a/core/lib/Drupal/Core/Config/Schema/TypedConfigInterface.php b/core/lib/Drupal/Core/Config/Schema/TypedConfigInterface.php index 22ffd78..0b5ea30 100644 --- a/core/lib/Drupal/Core/Config/Schema/TypedConfigInterface.php +++ b/core/lib/Drupal/Core/Config/Schema/TypedConfigInterface.php @@ -61,4 +61,12 @@ public function get($name); */ public function toArray(); + /** + * Gets the typed configuration manager. + * + * @return \Drupal\Core\Config\TypedConfigManagerInterface + * The typed configuration manager. + */ + public function getTypedConfigManager(); + } diff --git a/core/lib/Drupal/Core/TypedData/TypedDataInterface.php b/core/lib/Drupal/Core/TypedData/TypedDataInterface.php index 34636ba..b661814 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataInterface.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataInterface.php @@ -164,4 +164,15 @@ public function getPropertyPath(); * root of a typed data tree. Defaults to NULL. */ public function setContext($name = NULL, TraversableTypedDataInterface $parent = NULL); + + /** + * Sets the typed data manager. + * + * @param \Drupal\Core\TypedData\TypedDataManagerInterface $typed_data_manager + * The typed data manager. + * + * @return $this + */ + public function setTypedDataManager(TypedDataManagerInterface $typed_data_manager); + }