diff --git a/config_ignore_drush/composer.json b/config_ignore_drush/composer.json new file mode 100644 index 0000000..70e4fcd --- /dev/null +++ b/config_ignore_drush/composer.json @@ -0,0 +1,15 @@ +{ + "name": "drupal/config_ignore_drush", + "type": "drupal-drush", + "description": "Command replacement for config:import and config:export that applies sync and active storage filters rather than just sync.", + "require": { + "drupal/config_ignore": "^1.0" + }, + "extra": { + "drush": { + "services": { + "drush.services.yml": "^9" + } + } + } +} diff --git a/config_ignore_drush/config_ignore_drush.info.yml b/config_ignore_drush/config_ignore_drush.info.yml new file mode 100644 index 0000000..f961f29 --- /dev/null +++ b/config_ignore_drush/config_ignore_drush.info.yml @@ -0,0 +1,7 @@ +name: 'Config Ignore Drush Commands' +type: module +description: 'Command replacement for config:import, config:export and config:status that applies sync and active storage filters rather than just sync.' +core: 8.x +package: 'Config' +dependencies: + - config_ignore diff --git a/config_ignore_drush/drush.services.yml b/config_ignore_drush/drush.services.yml new file mode 100644 index 0000000..c0d2b37 --- /dev/null +++ b/config_ignore_drush/drush.services.yml @@ -0,0 +1,17 @@ +services: + config_ignore.export.commands: + class: \Drupal\config_ignore_drush\Commands\ConfigIgnoreExportCommands + arguments: ['@config.manager', '@config.storage', '@config.storage.sync', '@config_filter.storage_factory'] + tags: + - { name: drush.command } + config_ignore.import.commands: + class: \Drupal\config_ignore_drush\Commands\ConfigIgnoreImportCommands + arguments: ['@config.manager', '@config.storage', '@config.storage.sync', '@module_handler', '@event_dispatcher', '@lock', '@config.typed', '@module_installer', '@theme_handler', '@string_translation', '@config_filter.storage_factory'] + tags: + - { name: drush.command } + config_ignore.status.commands: + class: \Drupal\config_ignore_drush\Commands\ConfigIgnoreStatusCommands + arguments: ['@config.factory', '@config_filter.storage_factory'] + tags: + - { name: drush.command } + diff --git a/config_ignore_drush/src/Commands/ConfigIgnoreExportCommands.php b/config_ignore_drush/src/Commands/ConfigIgnoreExportCommands.php new file mode 100644 index 0000000..161bca4 --- /dev/null +++ b/config_ignore_drush/src/Commands/ConfigIgnoreExportCommands.php @@ -0,0 +1,42 @@ +filterFactory->getFilteredStorage(parent::getConfigStorage(), ['config.storage.active']); + } + + /** + * {@inheritdoc} + */ + public function __construct(\Drupal\Core\Config\ConfigManagerInterface $configManager, \Drupal\Core\Config\StorageInterface $configStorage, \Drupal\Core\Config\StorageInterface $configStorageSync, ConfigFilterStorageFactory $filter_factory) { + parent::__construct($configManager, $configStorage, $configStorageSync); + $this->filterFactory = $filter_factory; + } + + /** + * Replace config:export command. + * + * @hook replace-command config:export + */ + public function replaceExport($label = null, $options = ['add' => false, 'commit' => false, 'message' => self::REQ, 'destination' => self::OPT, 'diff' => false]) + { + parent::export($label, $options); + } +} diff --git a/config_ignore_drush/src/Commands/ConfigIgnoreImportCommands.php b/config_ignore_drush/src/Commands/ConfigIgnoreImportCommands.php new file mode 100644 index 0000000..0437044 --- /dev/null +++ b/config_ignore_drush/src/Commands/ConfigIgnoreImportCommands.php @@ -0,0 +1,52 @@ +filterFactory->getFilteredStorage(parent::getConfigStorage(), ['config.storage.active']); + } + + /** + * {@inheritdoc} + */ + public function __construct(ConfigManagerInterface $configManager, StorageInterface $configStorage, StorageInterface $configStorageSync, ModuleHandlerInterface $moduleHandler, EventDispatcherInterface $eventDispatcher, LockBackendInterface $lock, TypedConfigManagerInterface $configTyped, ModuleInstallerInterface $moduleInstaller, ThemeHandlerInterface $themeHandler, TranslationInterface $stringTranslation, ConfigFilterStorageFactory $filterFactory) + { + parent::__construct($configManager, $configStorage, $configStorageSync, $moduleHandler, $eventDispatcher, $lock, $configTyped, $moduleInstaller, $themeHandler, $stringTranslation); + $this->filterFactory = $filterFactory; + } + + /** + * Import config from a config directory. + * + * @hook replace-command config:import + */ + public function replaceImport($label = null, $options = ['preview' => 'list', 'source' => self::REQ, 'partial' => false, 'diff' => false]) + { + parent::import($label, $options); + } + +} diff --git a/config_ignore_drush/src/Commands/ConfigIgnoreStatusCommands.php b/config_ignore_drush/src/Commands/ConfigIgnoreStatusCommands.php new file mode 100644 index 0000000..80dbcf7 --- /dev/null +++ b/config_ignore_drush/src/Commands/ConfigIgnoreStatusCommands.php @@ -0,0 +1,43 @@ +filterFactory->getFilteredStorage(parent::getStorage($directory), ['config.storage.active']); + } + + /** + * {@inheritdoc} + */ + public function __construct(ConfigFactoryInterface $configFactory, ConfigFilterStorageFactory $filter_factory) { + parent::__construct($configFactory); + $this->filterFactory = $filter_factory; + } + + /** + * Replace config:status command. + * + * @hook replace-command config:status + */ + public function replaceStatus($options = ['state' => 'Only in DB,Only in sync dir,Different', 'prefix' => self::REQ, 'label' => self::REQ]) + { + parent::status($options); + } +}