diff --git a/src/Drupal/Commands/config/ConfigCommands.php b/src/Drupal/Commands/config/ConfigCommands.php index be25128081..3101771717 100644 --- a/src/Drupal/Commands/config/ConfigCommands.php +++ b/src/Drupal/Commands/config/ConfigCommands.php @@ -2,6 +2,7 @@ namespace Drush\Drupal\Commands\config; +use Drupal\Core\Config\ConfigDirectoryNotDefinedException; use Drupal\Core\Config\ImportStorageTransformer; use Consolidation\AnnotatedCommand\CommandError; use Consolidation\AnnotatedCommand\CommandData; @@ -389,7 +390,10 @@ public static function getDirectory($directory = null): string } } else { // If a directory isn't specified, use default sync directory. - $return = Settings::get('config_sync_directory'); + $return = Settings::get('config_sync_directory', false); + if ($return === false) { + throw new ConfigDirectoryNotDefinedException('The config sync directory is not defined in $settings["config_sync_directory"]'); + } } return Path::canonicalize($return); } diff --git a/src/Drupal/Commands/config/ConfigExportCommands.php b/src/Drupal/Commands/config/ConfigExportCommands.php index 9495c8118e..bf234fedeb 100644 --- a/src/Drupal/Commands/config/ConfigExportCommands.php +++ b/src/Drupal/Commands/config/ConfigExportCommands.php @@ -68,17 +68,21 @@ public function getConfigStorageSync(): StorageInterface return $this->configStorageSync; } + public function setConfigStorageSync(?StorageInterface $syncStorage): void + { + $this->configStorageSync = $syncStorage; + } + /** * @param ConfigManagerInterface $configManager * @param StorageInterface $configStorage * @param StorageInterface $configStorageSync */ - public function __construct(ConfigManagerInterface $configManager, StorageInterface $configStorage, StorageInterface $configStorageSync) + public function __construct(ConfigManagerInterface $configManager, StorageInterface $configStorage) { parent::__construct(); $this->configManager = $configManager; $this->configStorage = $configStorage; - $this->configStorageSync = $configStorageSync; } /** diff --git a/src/Drupal/Commands/config/ConfigImportCommands.php b/src/Drupal/Commands/config/ConfigImportCommands.php index 3db53e35c7..a3919c055a 100644 --- a/src/Drupal/Commands/config/ConfigImportCommands.php +++ b/src/Drupal/Commands/config/ConfigImportCommands.php @@ -81,6 +81,14 @@ public function getConfigStorageSync(): StorageInterface return $this->configStorageSync; } + /** + * @param StorageInterface|null $syncStorage + */ + public function setConfigStorageSync($syncStorage): void + { + $this->configStorageSync = $syncStorage; + } + public function getConfigCache(): CacheBackendInterface { return $this->configCache; @@ -164,7 +172,6 @@ public function getModuleExtensionList(): ModuleExtensionList public function __construct( ConfigManagerInterface $configManager, StorageInterface $configStorage, - StorageInterface $configStorageSync, CacheBackendInterface $configCache, ModuleHandlerInterface $moduleHandler, // Omit type hint as it changed in https://www.drupal.org/project/drupal/issues/3161983 @@ -179,7 +186,6 @@ public function __construct( parent::__construct(); $this->configManager = $configManager; $this->configStorage = $configStorage; - $this->configStorageSync = $configStorageSync; $this->configCache = $configCache; $this->moduleHandler = $moduleHandler; $this->eventDispatcher = $eventDispatcher; diff --git a/src/Drupal/Commands/config/drush.services.yml b/src/Drupal/Commands/config/drush.services.yml index f853f2d0f8..267a998f3a 100644 --- a/src/Drupal/Commands/config/drush.services.yml +++ b/src/Drupal/Commands/config/drush.services.yml @@ -10,9 +10,10 @@ services: - { name: drush.command } config.export.commands: class: \Drush\Drupal\Commands\config\ConfigExportCommands - arguments: ['@config.manager', '@config.storage', '@config.storage.sync'] + arguments: ['@config.manager', '@config.storage'] calls: - [setExportStorage, ['@?config.storage.export']] + - [setConfigStorageSync, ['@?config.storage.sync']] tags: - { name: drush.command } config.import.commands: @@ -20,7 +21,6 @@ services: arguments: - '@config.manager' - '@config.storage' - - '@config.storage.sync' - '@cache.config' - '@module_handler' - '@event_dispatcher' @@ -32,5 +32,6 @@ services: - '@extension.list.module' calls: - [setImportTransformer, ['@?config.import_transformer']] + - [setConfigStorageSync, ['@?config.storage.sync']] tags: - { name: drush.command }