diff --git a/drush.services.yml b/drush.services.yml new file mode 100644 index 0000000..e017767 --- /dev/null +++ b/drush.services.yml @@ -0,0 +1,6 @@ +services: + config_sync.commands: + class: \Drupal\config_sync\Commands\ConfigSyncCommands + arguments: ['@config_sync.lister', '@config_sync.initializer'] + tags: + - { name: drush.command } diff --git a/src/Commands/ConfigSyncCommands.php b/src/Commands/ConfigSyncCommands.php new file mode 100644 index 0000000..9aa2850 --- /dev/null +++ b/src/Commands/ConfigSyncCommands.php @@ -0,0 +1,98 @@ +configSyncLister = $configSyncLister; + $this->configSyncInitializer = $configSyncInitializer; + } + + /** + * Display a list of all extensions with available configuration updates. + * + * @command config-sync-list-updates + * @usage drush config-sync-list-updates + * Display a list of all extensions with available configuration updates. + * @aliases cs-list + * @field-labels + * type: Operation type + * id: Config ID + * label: Label + * extension_type: Extension type + * extension: Extension + * @default-fields extension,type,label + * @return \Consolidation\OutputFormatters\StructuredData\RowsOfFields + */ + public function syncListUpdates($options = ['format' => 'table']) { + $rows = []; + foreach ($this->configSyncLister->getExtensionChangelists() as $extension_type => $extensions) { + foreach ($extensions as $extension_id => $operation_types) { + foreach ($operation_types as $operation_type => $configurations) { + foreach ($configurations as $config_id => $config_label) { + $rows[$config_id] = [ + 'type' => $operation_type, + 'id' => $config_id, + 'label' => $config_label, + 'extension_type' => $extension_type, + 'extension' => $extension_id, + ]; + } + } + } + } + + return new RowsOfFields($rows); + } + + /** + * Apply configuration updates. + * + * @command config-sync-update + * @option retain-overrides Merge configuration updates with the active configuration, so that any overridden configuration is retained. + * @usage drush config-sync-update + * Apply updates to all extensions. + * @aliases cs-update + */ + public function syncUpdate($options = ['retain-overrides' => FALSE]) { + $this->configSyncInitializer->initialize($options['retain-overrides']); + + // @todo Import the merged configuration. + // @see \Drush\Drupal\Commands\config\ConfigImportCommands::import() + // @see \Drupal\config\Form\ConfigSync::buildForm() + } + + +}