core/core.services.yml | 4 ++-- core/lib/Drupal/Core/Config/Config.php | 17 +++-------------- core/lib/Drupal/Core/Config/ConfigFactory.php | 17 +++-------------- core/lib/Drupal/Core/Config/ConfigInstaller.php | 15 ++------------- core/tests/Drupal/Tests/Core/Config/ConfigTest.php | 6 +++++- 5 files changed, 15 insertions(+), 44 deletions(-) diff --git a/core/core.services.yml b/core/core.services.yml index bd8660d..883b79e2 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -134,10 +134,10 @@ services: tags: - { name: event_subscriber } - { name: service_collector, tag: 'config.factory.override', call: addOverride } - arguments: ['@config.storage', '@event_dispatcher', '@config.typed', '@cache_tags.invalidator'] + arguments: ['@config.storage', '@event_dispatcher', '@config.typed'] config.installer: class: Drupal\Core\Config\ConfigInstaller - arguments: ['@config.factory', '@config.storage', '@config.typed', '@config.manager', '@event_dispatcher', '@cache_tags.invalidator'] + arguments: ['@config.factory', '@config.storage', '@config.typed', '@config.manager', '@event_dispatcher'] config.storage: class: Drupal\Core\Config\CachedStorage arguments: ['@config.storage.active', '@cache.config'] diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index a5e745d..bc6ba29 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; -use Drupal\Core\Cache\CacheTagsInvalidatorInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -56,13 +55,6 @@ class Config extends StorableConfigBase { protected $settingsOverrides; /** - * The cache tags invalidator. - * - * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface - */ - protected $cacheTagsInvalidator; - - /** * Constructs a configuration object. * * @param string $name @@ -74,15 +66,12 @@ class Config extends StorableConfigBase { * An event dispatcher instance to use for configuration events. * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config * The typed configuration manager service. - * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator - * The cache tags invalidator. */ - public function __construct($name, StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config, CacheTagsInvalidatorInterface $cache_tags_invalidator) { + public function __construct($name, StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config) { $this->name = $name; $this->storage = $storage; $this->eventDispatcher = $event_dispatcher; $this->typedConfigManager = $typed_config; - $this->cacheTagsInvalidator = $cache_tags_invalidator; } /** @@ -235,7 +224,7 @@ public function save() { } $this->storage->write($this->name, $this->data); - $this->cacheTagsInvalidator->invalidateTags($this->getCacheTags()); + Cache::invalidateTags($this->getCacheTags()); $this->isNew = FALSE; $this->eventDispatcher->dispatch(ConfigEvents::SAVE, new ConfigCrudEvent($this)); $this->originalData = $this->data; @@ -251,7 +240,7 @@ public function save() { public function delete() { $this->data = array(); $this->storage->delete($this->name); - $this->cacheTagsInvalidator->invalidateTags($this->getCacheTags()); + Cache::invalidateTags($this->getCacheTags()); $this->isNew = TRUE; $this->resetOverriddenData(); $this->eventDispatcher->dispatch(ConfigEvents::DELETE, new ConfigCrudEvent($this)); diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index 313f23e..b1a8932 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Config; use Drupal\Component\Utility\NestedArray; -use Drupal\Core\Cache\CacheTagsInvalidatorInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -72,13 +71,6 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface protected $configFactoryOverrides = array(); /** - * The cache tags invalidator. - * - * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface - */ - protected $cacheTagsInvalidator; - - /** * Constructs the Config factory. * * @param \Drupal\Core\Config\StorageInterface $storage @@ -87,14 +79,11 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface * An event dispatcher instance to use for configuration events. * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config * The typed configuration manager. - * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator - * The cache tags invalidator. */ - public function __construct(StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config, CacheTagsInvalidatorInterface $cache_tags_invalidator) { + public function __construct(StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config) { $this->storage = $storage; $this->eventDispatcher = $event_dispatcher; $this->typedConfigManager = $typed_config; - $this->cacheTagsInvalidator = $cache_tags_invalidator; } /** @@ -123,7 +112,7 @@ public function get($name) { // If the configuration object does not exist in the configuration // storage, create a new object and add it to the static cache. $cache_key = $this->getConfigCacheKey($name); - $this->cache[$cache_key] = new Config($name, $this->storage, $this->eventDispatcher, $this->typedConfigManager, $this->cacheTagsInvalidator); + $this->cache[$cache_key] = new Config($name, $this->storage, $this->eventDispatcher, $this->typedConfigManager); if ($this->useOverrides) { // Get and apply any overrides. @@ -168,7 +157,7 @@ public function loadMultiple(array $names) { foreach ($storage_data as $name => $data) { $cache_key = $this->getConfigCacheKey($name); - $this->cache[$cache_key] = new Config($name, $this->storage, $this->eventDispatcher, $this->typedConfigManager, $this->cacheTagsInvalidator); + $this->cache[$cache_key] = new Config($name, $this->storage, $this->eventDispatcher, $this->typedConfigManager); $this->cache[$cache_key]->initWithData($data); if ($this->useOverrides) { if (isset($module_overrides[$name])) { diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php index 7f9207b..72ae554 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Config; use Drupal\Component\Utility\Unicode; -use Drupal\Core\Cache\CacheTagsInvalidatorInterface; use Drupal\Core\Config\Entity\ConfigDependencyManager; use Drupal\Core\Site\Settings; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -51,13 +50,6 @@ class ConfigInstaller implements ConfigInstallerInterface { protected $eventDispatcher; /** - * The cache tags invalidator. - * - * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface - */ - protected $cacheTagsInvalidator; - - /** * The configuration storage that provides the default configuration. * * @var \Drupal\Core\Config\StorageInterface @@ -84,16 +76,13 @@ class ConfigInstaller implements ConfigInstallerInterface { * The configuration manager. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher. - * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator - * The cache tags invalidator. */ - public function __construct(ConfigFactoryInterface $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher, CacheTagsInvalidatorInterface $cache_tags_invalidator) { + public function __construct(ConfigFactoryInterface $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher) { $this->configFactory = $config_factory; $this->activeStorage = $active_storage; $this->typedConfig = $typed_config; $this->configManager = $config_manager; $this->eventDispatcher = $event_dispatcher; - $this->cacheTagsInvalidator = $cache_tags_invalidator; } /** @@ -211,7 +200,7 @@ protected function createConfiguration($collection, array $config_to_install) { $new_config = $overrider->createConfigObject($name, $collection); } else { - $new_config = new Config($name, $this->getActiveStorage($collection), $this->eventDispatcher, $this->typedConfig, $this->cacheTagsInvalidator); + $new_config = new Config($name, $this->getActiveStorage($collection), $this->eventDispatcher, $this->typedConfig); } if ($data[$name] !== FALSE) { $new_config->setData($data[$name]); diff --git a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php index 7a872be..549e28a 100644 --- a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php +++ b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php @@ -62,8 +62,12 @@ public function setUp() { $this->storage = $this->getMock('Drupal\Core\Config\StorageInterface'); $this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); $this->typedConfig = $this->getMock('\Drupal\Core\Config\TypedConfigManagerInterface'); + $this->config = new Config('config.test', $this->storage, $this->eventDispatcher, $this->typedConfig); $this->cacheTagsInvalidator = $this->getMock('Drupal\Core\Cache\CacheTagsInvalidatorInterface'); - $this->config = new Config('config.test', $this->storage, $this->eventDispatcher, $this->typedConfig, $this->cacheTagsInvalidator); + + $container = new ContainerBuilder(); + $container->set('cache_tags.invalidator', $this->cacheTagsInvalidator); + \Drupal::setContainer($container); } /**