diff --git a/core/modules/config_translation/src/ConfigEntityMapper.php b/core/modules/config_translation/src/ConfigEntityMapper.php index b16d27d..aa92fcd 100644 --- a/core/modules/config_translation/src/ConfigEntityMapper.php +++ b/core/modules/config_translation/src/ConfigEntityMapper.php @@ -8,6 +8,7 @@ namespace Drupal\config_translation; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Routing\RouteProviderInterface; @@ -61,6 +62,8 @@ class ConfigEntityMapper extends ConfigNamesMapper { * - entity_type: The name of the entity type this mapper belongs to. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The configuration factory. + * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config + * The typed configuration manager. * @param \Drupal\locale\LocaleConfigManager $locale_config_manager * The locale configuration manager. * @param \Drupal\config_translation\ConfigMapperManagerInterface $config_mapper_manager @@ -72,8 +75,8 @@ class ConfigEntityMapper extends ConfigNamesMapper { * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. */ - public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityManagerInterface $entity_manager) { - parent::__construct($plugin_id, $plugin_definition, $config_factory, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager); + public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityManagerInterface $entity_manager) { + parent::__construct($plugin_id, $plugin_definition, $config_factory, $typed_config, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager); $this->setType($plugin_definition['entity_type']); $this->entityManager = $entity_manager; @@ -89,6 +92,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $container->get('config.factory'), + $container->get('config.typed'), $container->get('locale.config.typed'), $container->get('plugin.manager.config_translation.mapper'), $container->get('router.route_provider'), diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php index 68c0623..57811d9 100644 --- a/core/modules/config_translation/src/ConfigNamesMapper.php +++ b/core/modules/config_translation/src/ConfigNamesMapper.php @@ -8,6 +8,7 @@ namespace Drupal\config_translation; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Plugin\PluginBase; @@ -33,6 +34,13 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con protected $configFactory; /** + * The typed config manager. + * + * @var \Drupal\Core\Config\TypedConfigManagerInterface + */ + protected $typedConfigManager; + + /** * The typed configuration manager. * * @var \Drupal\locale\LocaleConfigManager @@ -91,6 +99,8 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con * generate lists of this type of configuration. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The configuration factory. + * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config + * The typed configuration manager. * @param \Drupal\locale\LocaleConfigManager $locale_config_manager * The locale configuration manager. * @param \Drupal\config_translation\ConfigMapperManagerInterface $config_mapper_manager @@ -104,12 +114,13 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con * Throws an exception if the route specified by the 'base_route_name' in * the plugin definition could not be found by the route provider. */ - public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation) { + public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation) { $this->pluginId = $plugin_id; $this->pluginDefinition = $plugin_definition; $this->routeProvider = $route_provider; $this->configFactory = $config_factory; + $this->typedConfigManager = $typed_config; $this->localeConfigManager = $locale_config_manager; $this->configMapperManager = $config_mapper_manager; @@ -126,6 +137,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $container->get('config.factory'), + $container->get('config.typed'), $container->get('locale.config.typed'), $container->get('plugin.manager.config_translation.mapper'), $container->get('router.route_provider'), @@ -435,7 +447,7 @@ public function getConfigData() { */ public function hasSchema() { foreach ($this->getConfigNames() as $name) { - if (!$this->localeConfigManager->hasConfigSchema($name)) { + if (!$this->typedConfigManager->hasConfigSchema($name)) { return FALSE; } } diff --git a/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php b/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php index bdc04f8..4a27390 100644 --- a/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php +++ b/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php @@ -79,6 +79,9 @@ public function setUp() { 'entity_type' => 'language_entity', 'route_name' => 'config_translation.item.overview.language.edit', ); + + $typed_config_manager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'); + $locale_config_manager = $this->getMockBuilder('Drupal\locale\LocaleConfigManager') ->disableOriginalConstructor() ->getMock(); @@ -87,6 +90,7 @@ public function setUp() { 'language_entity', $definition, $this->getConfigFactoryStub(), + $typed_config_manager, $locale_config_manager, $this->getMock('Drupal\config_translation\ConfigMapperManagerInterface'), $this->routeProvider, diff --git a/core/modules/config_translation/tests/src/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/ConfigNamesMapperTest.php index 41a6b1a..70b82de 100644 --- a/core/modules/config_translation/tests/src/ConfigNamesMapperTest.php +++ b/core/modules/config_translation/tests/src/ConfigNamesMapperTest.php @@ -46,6 +46,13 @@ class ConfigNamesMapperTest extends UnitTestCase { protected $localeConfigManager; /** + * The locale configuration manager. + * + * @var \Drupal\locale\LocaleConfigManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $typedConfigManager; + + /** * The configuration mapper manager. * * @var \Drupal\config_translation\ConfigMapperManagerInterface|\PHPUnit_Framework_MockObject_MockObject @@ -88,6 +95,8 @@ public function setUp() { 'weight' => 42, ); + $this->typedConfigManager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'); + $this->localeConfigManager = $this->getMockBuilder('Drupal\locale\LocaleConfigManager') ->disableOriginalConstructor() ->getMock(); @@ -106,6 +115,7 @@ public function setUp() { 'system.site_information_settings', $this->pluginDefinition, $this->getConfigFactoryStub(), + $this->typedConfigManager, $this->localeConfigManager, $this->configMapperManager, $this->routeProvider, @@ -468,7 +478,7 @@ public function testHasSchema(array $mock_return_values, $expected) { foreach ($config_names as $i => $config_name) { $map[] = array($config_name, $mock_return_values[$i]); } - $this->localeConfigManager + $this->typedConfigManager ->expects($this->any()) ->method('hasConfigSchema') ->will($this->returnValueMap($map)); diff --git a/core/modules/locale/locale.services.yml b/core/modules/locale/locale.services.yml index f7794c3..7a0ced3 100644 --- a/core/modules/locale/locale.services.yml +++ b/core/modules/locale/locale.services.yml @@ -1,7 +1,7 @@ services: locale.config.typed: class: Drupal\locale\LocaleConfigManager - arguments: ['@config.storage', '@config.storage.schema', '@config.storage.installer', '@locale.storage', '@cache.discovery', '@config.factory', '@language_manager'] + arguments: ['@config.storage', '@config.storage.installer', '@locale.storage', '@config.factory', '@config.typed', '@language_manager'] locale.storage: class: Drupal\locale\StringDatabaseStorage arguments: ['@database'] diff --git a/core/modules/locale/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php index 5466558..feacd0c 100644 --- a/core/modules/locale/src/LocaleConfigManager.php +++ b/core/modules/locale/src/LocaleConfigManager.php @@ -8,7 +8,7 @@ namespace Drupal\locale; use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Config\TypedConfigManager; +use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Language\LanguageInterface; @@ -17,7 +17,14 @@ /** * Manages localized configuration type plugins. */ -class LocaleConfigManager extends TypedConfigManager { +class LocaleConfigManager { + + /** + * A storage instance for reading configuration data. + * + * @var \Drupal\Core\Config\StorageInterface + */ + protected $configStorage; /** * A storage instance for reading default configuration data. @@ -53,30 +60,36 @@ class LocaleConfigManager extends TypedConfigManager { protected $languageManager; /** + * The typed config manager. + * + * @var \Drupal\Core\Config\TypedConfigManagerInterface + */ + protected $typedConfigManager; + + /** * Creates a new typed configuration manager. * * @param \Drupal\Core\Config\StorageInterface $configStorage * The storage object to use for reading configuration data. - * @param \Drupal\Core\Config\StorageInterface $schemaStorage - * The storage object to use for reading schema data. * @param \Drupal\Core\Config\StorageInterface $installStorage * The storage object to use for reading default configuration * data. * @param \Drupal\locale\StringStorageInterface $localeStorage * The locale storage to use for reading string translations. - * @param \Drupal\Core\Cache\CacheBackendInterface $cache - * The cache backend to use for caching the definitions. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The configuration factory + * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config + * The typed configuration manager. * @param \Drupal\language\ConfigurableLanguageManagerInterface * The language manager. */ - public function __construct(StorageInterface $configStorage, StorageInterface $schemaStorage, StorageInterface $installStorage, StringStorageInterface $localeStorage, CacheBackendInterface $cache, ConfigFactoryInterface $config_factory, ConfigurableLanguageManagerInterface $language_manager) { - // Note we use the install storage for the parent constructor. - parent::__construct($configStorage, $schemaStorage, $cache); + public function __construct(StorageInterface $configStorage, StorageInterface $installStorage, StringStorageInterface $localeStorage, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, ConfigurableLanguageManagerInterface $language_manager) { + $this->typedConfigManager = $typed_config; + $this->configStorage = $configStorage; $this->installStorage = $installStorage; $this->localeStorage = $localeStorage; $this->configFactory = $config_factory; + $this->typedConfigManager = $typed_config; $this->languageManager = $language_manager; } @@ -95,11 +108,11 @@ public function get($name) { $updated = $this->configStorage->read($name); // We get only the data that didn't change from default. $data = $this->compareConfigData($default, $updated); - $definition = $this->getDefinition($name); - $data_definition = $this->buildDataDefinition($definition, $data); + $definition = $this->typedConfigManager->getDefinition($name); + $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $data); // Unless the configuration has a explicit language code we assume English. $langcode = isset($default['langcode']) ? $default['langcode'] : 'en'; - $wrapper = new LocaleTypedConfig($data_definition, $name, $langcode, $this); + $wrapper = new LocaleTypedConfig($data_definition, $name, $langcode, $this, $this->typedConfigManager); $wrapper->setValue($data); return $wrapper; } diff --git a/core/modules/locale/src/LocaleTypedConfig.php b/core/modules/locale/src/LocaleTypedConfig.php index 36e39a9..eeccaa8 100644 --- a/core/modules/locale/src/LocaleTypedConfig.php +++ b/core/modules/locale/src/LocaleTypedConfig.php @@ -11,6 +11,7 @@ use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\Config\Schema\Element; use Drupal\Core\Config\Schema\ArrayElement; +use Drupal\Core\Config\TypedConfigManagerInterface; /** * Defines the locale configuration wrapper object. @@ -39,6 +40,13 @@ class LocaleTypedConfig extends Element { protected $localeConfig; /** + * The typed config manager. + * + * @var \Drupal\Core\Config\TypedConfigManagerInterface + */ + protected $typedConfigManager; + + /** * Constructs a configuration wrapper object. * * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition @@ -50,17 +58,18 @@ class LocaleTypedConfig extends Element { * @param \Drupal\locale\LocaleConfigManager $localeConfig; * The locale configuration manager object. */ - public function __construct(DataDefinitionInterface $definition, $name, $langcode, LocaleConfigManager $localeConfig) { + public function __construct(DataDefinitionInterface $definition, $name, $langcode, LocaleConfigManager $localeConfig, TypedConfigManagerInterface $typed_config) { parent::__construct($definition, $name); $this->langcode = $langcode; $this->localeConfig = $localeConfig; + $this->typedConfigManager = $typed_config; } /** * Gets wrapped typed config object. */ public function getTypedConfig() { - return $this->localeConfig->create($this->definition, $this->value); + return $this->typedConfigManager->create($this->definition, $this->value); } /** @@ -72,7 +81,7 @@ public function getTranslation($langcode) { 'target' => $langcode, ); $data = $this->getElementTranslation($this->getTypedConfig(), $options); - return $this->localeConfig->create($this->definition, $data); + return $this->typedConfigManager->create($this->definition, $data); } /**