diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index 896b08e..c43ad8d 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -123,7 +123,12 @@ public function createInstance($plugin_id, array $configuration, $name = NULL, $ if (!isset($class)) { throw new PluginException(sprintf('The plugin (%s) did not specify an instance class.', $plugin_id)); } - return new $class($configuration, $name, $parent); + if (class_implements($class, '\Drupal\Core\Plugin\ContainerFactoryPluginInterface')) { + return $class::create(\Drupal::getContainer(), $configuration, $name, $type_definition, $parent); + } + else { + return new $class($configuration, $name, $parent); + } } /** diff --git a/core/lib/Drupal/Core/TypedData/TypedData.php b/core/lib/Drupal/Core/TypedData/TypedData.php index 7e4161a..4598141 100644 --- a/core/lib/Drupal/Core/TypedData/TypedData.php +++ b/core/lib/Drupal/Core/TypedData/TypedData.php @@ -162,7 +162,7 @@ public function getConstraints() { * Implements \Drupal\Core\TypedData\TypedDataInterface::validate(). */ public function validate() { - return $this->typedDataManager()->getValidator()->validate($this); + return $this->typedDataManager->getValidator()->validate($this); } /** diff --git a/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php b/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php index 8cba49a..e0b7e2c 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php @@ -10,6 +10,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\Config\TypedConfigManager; use Drupal\Core\Config\StorageInterface; +use Drupal\Core\TypedData\TypedDataManager; /** * Manages localized configuration type plugins. @@ -36,6 +37,14 @@ class LocaleConfigManager extends TypedConfigManager { protected $translations; /** + * The typed data plugin manager. + * + * @var \Drupal\Core\TypedData\TypedDataManager + */ + protected $typedDataManager; + + + /** * Creates a new typed configuration manager. * * @param \Drupal\Core\Config\StorageInterface $configStorage @@ -47,12 +56,15 @@ class LocaleConfigManager extends TypedConfigManager { * data. * @param \Drupal\locale\StringStorageInterface $localeStorage * The locale storage to use for reading string translations. + * @param \Drupal\Core\TypedData\TypedDataManager $typed_data_manager + * The typed data manager service. */ - public function __construct(StorageInterface $configStorage, StorageInterface $schemaStorage, StorageInterface $installStorage, StringStorageInterface $localeStorage) { + public function __construct(StorageInterface $configStorage, StorageInterface $schemaStorage, StorageInterface $installStorage, StringStorageInterface $localeStorage, TypedDataManager $typed_data_manager) { // Note we use the install storage for the parent constructor. parent::__construct($configStorage, $schemaStorage); $this->installStorage = $installStorage; $this->localeStorage = $localeStorage; + $this->typedDataManager = $typed_data_manager; } /** @@ -73,7 +85,7 @@ public function get($name) { $definition = $this->getDefinition($name); // Unless the configuration has a explicit language code we assume English. $langcode = isset($default['langcode']) ? $default['langcode'] : 'en'; - $wrapper = new LocaleTypedConfig($definition, $name, $langcode, $this); + $wrapper = new LocaleTypedConfig($definition, $name, $langcode, $this, $this->typedDataManager); $wrapper->setValue($data); return $wrapper; } diff --git a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php index 5d6b200..226d104 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php @@ -9,6 +9,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\TypedData\ContextAwareInterface; +use Drupal\Core\TypedData\TypedDataManager; use Drupal\Core\Config\Schema\Element; use Drupal\Core\Config\Schema\ArrayElement; @@ -49,9 +50,11 @@ class LocaleTypedConfig extends Element { * Language code for the source configuration data. * @param \Drupal\locale\LocaleConfigManager $localeConfig; * The locale configuration manager object. + * @param \Drupal\Core\TypedData\TypedDataManager $typed_data_manager + * The typed data plugin manager. */ - public function __construct(array $definition, $name, $langcode, \Drupal\locale\LocaleConfigManager $localeConfig) { - parent::__construct($definition, $name); + public function __construct(array $definition, $name, $langcode, \Drupal\locale\LocaleConfigManager $localeConfig, TypedDataManager $typed_data_manager) { + parent::__construct($definition, $name, NULL, $typed_data_manager); $this->langcode = $langcode; $this->localeConfig = $localeConfig; } diff --git a/core/modules/locale/locale.services.yml b/core/modules/locale/locale.services.yml index f632704..64dc3fc 100644 --- a/core/modules/locale/locale.services.yml +++ b/core/modules/locale/locale.services.yml @@ -6,7 +6,7 @@ services: arguments: ['@language_manager', '@config.context'] locale.config.typed: class: Drupal\locale\LocaleConfigManager - arguments: ['@config.storage', '@config.storage.schema', '@config.storage.installer', '@locale.storage'] + arguments: ['@config.storage', '@config.storage.schema', '@config.storage.installer', '@locale.storage', '@typed_data'] locale.storage: class: Drupal\locale\StringDatabaseStorage arguments: ['@database']