config_inspector.services.yml | 5 ++++- drush.services.yml | 5 +---- src/Commands/InspectorCommands.php | 20 +------------------- src/ConfigInspectorManager.php | 11 ++++++++++- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/config_inspector.services.yml b/config_inspector.services.yml index 2aff15a..9ef6588 100644 --- a/config_inspector.services.yml +++ b/config_inspector.services.yml @@ -1,4 +1,7 @@ services: config_inspector.manager: class: Drupal\config_inspector\ConfigInspectorManager - arguments: ['@config.factory', '@config.typed'] + arguments: + - '@config.factory' + - '@config.typed' + - '@cache.discovery' diff --git a/drush.services.yml b/drush.services.yml index f4797c8..8d66c0e 100644 --- a/drush.services.yml +++ b/drush.services.yml @@ -1,9 +1,6 @@ services: config_inspector.commands: class: Drupal\config_inspector\Commands\InspectorCommands - arguments: - - '@config_inspector.manager' - - '@config.storage' - - '@cache.discovery' + arguments: ['@config_inspector.manager', '@config.storage'] tags: - { name: drush.command } diff --git a/src/Commands/InspectorCommands.php b/src/Commands/InspectorCommands.php index e68b0f2..5f4898e 100644 --- a/src/Commands/InspectorCommands.php +++ b/src/Commands/InspectorCommands.php @@ -5,7 +5,6 @@ namespace Drupal\config_inspector\Commands; use Consolidation\AnnotatedCommand\CommandResult; use Consolidation\OutputFormatters\StructuredData\RowsOfFields; use Drupal\config_inspector\ConfigInspectorManager; -use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\StorageInterface; use Drush\Commands\DrushCommands; @@ -28,13 +27,6 @@ class InspectorCommands extends DrushCommands { */ protected $activeStorage; - /** - * The discovery cache. - * - * @var \Drupal\Core\Cache\CacheBackendInterface - */ - protected $discoveryCache; - /** * Constructs InspectorCommands object. * @@ -42,14 +34,11 @@ class InspectorCommands extends DrushCommands { * The configuration inspector manager. * @param \Drupal\Core\Config\StorageInterface $storage * The active configuration storage. - * @param \Drupal\Core\Cache\CacheBackendInterface $discovery_cache - * The discovery cache. */ - public function __construct(ConfigInspectorManager $config_inspector_manager, StorageInterface $storage, CacheBackendInterface $discovery_cache) { + public function __construct(ConfigInspectorManager $config_inspector_manager, StorageInterface $storage) { parent::__construct(); $this->inspector = $config_inspector_manager; $this->activeStorage = $storage; - $this->discoveryCache = $discovery_cache; } /** @@ -91,13 +80,6 @@ class InspectorCommands extends DrushCommands { 'detail' => FALSE, 'skip-keys' => '', ]) { - - // Always inspect an up-to-date configuration schema. - $this->discoveryCache->deleteMultiple([ - 'typed_config_definitions', - 'validation_constraint_plugins', - ]); - $rows = []; $exitCode = self::EXIT_SUCCESS; $keys = empty($key) ? $this->activeStorage->listAll() : [$key]; diff --git a/src/ConfigInspectorManager.php b/src/ConfigInspectorManager.php index d43681f..1f61870 100644 --- a/src/ConfigInspectorManager.php +++ b/src/ConfigInspectorManager.php @@ -2,6 +2,7 @@ namespace Drupal\config_inspector; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Config\Schema\Element; @@ -36,10 +37,18 @@ class ConfigInspectorManager { * The configuration factory. * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config_manager * The typed configuration manager. + * @param \Drupal\Core\Cache\CacheBackendInterface $discovery_cache + * The discovery cache. */ - public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager) { + public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager, CacheBackendInterface $discovery_cache) { $this->configFactory = $config_factory; $this->typedConfigManager = $typed_config_manager; + + // Always inspect an up-to-date configuration schema. + $discovery_cache->deleteMultiple([ + 'typed_config_definitions', + 'validation_constraint_plugins', + ]); } /**