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..5de08db --- /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 and config:export 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..b191397 --- /dev/null +++ b/config_ignore_drush/drush.services.yml @@ -0,0 +1,24 @@ +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' + - '@cache.config' + - '@module_handler' + - '@event_dispatcher' + - '@lock' + - '@config.typed' + - '@module_installer' + - '@theme_handler' + - '@string_translation' + - '@extension.list.module' + - '@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..efd339b --- /dev/null +++ b/config_ignore_drush/src/Commands/ConfigIgnoreImportCommands.php @@ -0,0 +1,68 @@ +filterFactory->getFilteredStorage(parent::getConfigStorage(), ['config.storage.active']); + } + + /** + * {@inheritdoc} + */ + 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 + $eventDispatcher, + LockBackendInterface $lock, + TypedConfigManagerInterface $configTyped, + ModuleInstallerInterface $moduleInstaller, + ThemeHandlerInterface $themeHandler, + TranslationInterface $stringTranslation, + ModuleExtensionList $moduleExtensionList, + ConfigFilterStorageFactory $filterFactory + ){ + parent::__construct($configManager, $configStorage, $configStorageSync, $configCache, $moduleHandler, $eventDispatcher, $lock, $configTyped, $moduleInstaller, $themeHandler, $stringTranslation, $moduleExtensionList); + $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); + } + +}