Loading drush.services.yml +1 −0 Original line number Diff line number Diff line Loading @@ -6,5 +6,6 @@ services: - '@config.storage' - '@config.manager' - '@config.import.commands' - '@state' tags: - { name: drush.command } src/Commands/ConfigSyncCommands.php +36 −1 Original line number Diff line number Diff line Loading @@ -2,10 +2,12 @@ namespace Drupal\config_sync\Commands; use Consolidation\AnnotatedCommand\CommandData; use Consolidation\OutputFormatters\StructuredData\RowsOfFields; use Drupal\config_sync\ConfigSyncListerInterface; use Drupal\Core\Config\ConfigManagerInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\State\StateInterface; use Drush\Commands\DrushCommands; use Drush\Drupal\Commands\config\ConfigCommands; use Drush\Drupal\Commands\config\ConfigImportCommands; Loading Loading @@ -44,6 +46,13 @@ class ConfigSyncCommands extends DrushCommands { */ protected $configImportCommands; /** * The state service. * * @var \Drupal\Core\State\StateInterface */ protected $state; /** * Constructs a new ConfigSyncCommands object. * Loading @@ -55,13 +64,16 @@ class ConfigSyncCommands extends DrushCommands { * The configuration manager. * @param \Drush\Drupal\Commands\config\ConfigImportCommands $configImportCommands * The service containing Drush commands for regular core config imports. * @param \Drupal\Core\State\StateInterface $state. * The state service. */ public function __construct(ConfigSyncListerInterface $configSyncLister, StorageInterface $activeStorage, ConfigManagerInterface $configManager, ConfigImportCommands $configImportCommands) { public function __construct(ConfigSyncListerInterface $configSyncLister, StorageInterface $activeStorage, ConfigManagerInterface $configManager, ConfigImportCommands $configImportCommands, StateInterface $state) { parent::__construct(); $this->configSyncLister = $configSyncLister; $this->activeStorage = $activeStorage; $this->configManager = $configManager; $this->configImportCommands = $configImportCommands; $this->state = $state; } /** Loading Loading @@ -105,4 +117,27 @@ class ConfigSyncCommands extends DrushCommands { return new RowsOfFields($rows); } /** * Adds an option to the config-distro-update command. * * @hook option config-distro-update * @option update-mode Specify a mode for updates. Options are 1 (merge), 2 (partial reset), and 3 (full reset). * @usage drush config-distro-update --update-mode=2 * Run a config distro update with the update mode of 2 (partial reset). */ public function optionsetConfigDistroUpdate($options = ['update-mode' => self::OPT]) { } /** * Sets the specified update mode in the state. * * @hook pre-command config-distro-update */ public function preConfigDistroUpdate(CommandData $commandData) { $updateMode = $commandData->input()->getOption('update-mode'); if (!empty($updateMode)) { $this->state->set('config_sync.update_mode', (int) $updateMode); } } } src/ConfigSyncSnapshotterInterface.php +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ interface ConfigSyncSnapshotterInterface { const SNAPSHOT_MODE_IMPORT = 'import'; /** * Install snapshot mode. * Name of snapshot set for config_sync. */ const CONFIG_SNAPSHOT_SET = 'config_sync'; Loading Loading
drush.services.yml +1 −0 Original line number Diff line number Diff line Loading @@ -6,5 +6,6 @@ services: - '@config.storage' - '@config.manager' - '@config.import.commands' - '@state' tags: - { name: drush.command }
src/Commands/ConfigSyncCommands.php +36 −1 Original line number Diff line number Diff line Loading @@ -2,10 +2,12 @@ namespace Drupal\config_sync\Commands; use Consolidation\AnnotatedCommand\CommandData; use Consolidation\OutputFormatters\StructuredData\RowsOfFields; use Drupal\config_sync\ConfigSyncListerInterface; use Drupal\Core\Config\ConfigManagerInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\State\StateInterface; use Drush\Commands\DrushCommands; use Drush\Drupal\Commands\config\ConfigCommands; use Drush\Drupal\Commands\config\ConfigImportCommands; Loading Loading @@ -44,6 +46,13 @@ class ConfigSyncCommands extends DrushCommands { */ protected $configImportCommands; /** * The state service. * * @var \Drupal\Core\State\StateInterface */ protected $state; /** * Constructs a new ConfigSyncCommands object. * Loading @@ -55,13 +64,16 @@ class ConfigSyncCommands extends DrushCommands { * The configuration manager. * @param \Drush\Drupal\Commands\config\ConfigImportCommands $configImportCommands * The service containing Drush commands for regular core config imports. * @param \Drupal\Core\State\StateInterface $state. * The state service. */ public function __construct(ConfigSyncListerInterface $configSyncLister, StorageInterface $activeStorage, ConfigManagerInterface $configManager, ConfigImportCommands $configImportCommands) { public function __construct(ConfigSyncListerInterface $configSyncLister, StorageInterface $activeStorage, ConfigManagerInterface $configManager, ConfigImportCommands $configImportCommands, StateInterface $state) { parent::__construct(); $this->configSyncLister = $configSyncLister; $this->activeStorage = $activeStorage; $this->configManager = $configManager; $this->configImportCommands = $configImportCommands; $this->state = $state; } /** Loading Loading @@ -105,4 +117,27 @@ class ConfigSyncCommands extends DrushCommands { return new RowsOfFields($rows); } /** * Adds an option to the config-distro-update command. * * @hook option config-distro-update * @option update-mode Specify a mode for updates. Options are 1 (merge), 2 (partial reset), and 3 (full reset). * @usage drush config-distro-update --update-mode=2 * Run a config distro update with the update mode of 2 (partial reset). */ public function optionsetConfigDistroUpdate($options = ['update-mode' => self::OPT]) { } /** * Sets the specified update mode in the state. * * @hook pre-command config-distro-update */ public function preConfigDistroUpdate(CommandData $commandData) { $updateMode = $commandData->input()->getOption('update-mode'); if (!empty($updateMode)) { $this->state->set('config_sync.update_mode', (int) $updateMode); } } }
src/ConfigSyncSnapshotterInterface.php +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ interface ConfigSyncSnapshotterInterface { const SNAPSHOT_MODE_IMPORT = 'import'; /** * Install snapshot mode. * Name of snapshot set for config_sync. */ const CONFIG_SNAPSHOT_SET = 'config_sync'; Loading