Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make config.storage.sync injection optional and log any issues #5204

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Drupal/Commands/config/ConfigCommands.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 6 additions & 2 deletions src/Drupal/Commands/config/ConfigExportCommands.php
Expand Up @@ -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;
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/Drupal/Commands/config/ConfigImportCommands.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/Drupal/Commands/config/drush.services.yml
Expand Up @@ -10,17 +10,17 @@ 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:
class: \Drush\Drupal\Commands\config\ConfigImportCommands
arguments:
- '@config.manager'
- '@config.storage'
- '@config.storage.sync'
- '@cache.config'
- '@module_handler'
- '@event_dispatcher'
Expand All @@ -32,5 +32,6 @@ services:
- '@extension.list.module'
calls:
- [setImportTransformer, ['@?config.import_transformer']]
- [setConfigStorageSync, ['@?config.storage.sync']]
tags:
- { name: drush.command }