Skip to content
Snippets Groups Projects
Commit 3f1f2fa9 authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3393190 by jurgenhaas: Drupal 10 only version

parent 178d26c5
No related branches found
No related tags found
No related merge requests found
Pipeline #29111 failed
services:
config_auto_export.commands:
class: Drupal\config_auto_export\Commands\ConfigAutoExportCommands
tags:
- { name: drush.command }
arguments:
- '@config.manager'
- '@diff.formatter'
- '@config.storage'
- '@config_auto_export.storage'
- '@config_auto_export.service'
- '@renderer'
<?php
namespace Drupal\config_auto_export\Commands;
namespace Drupal\config_auto_export\Drush\Commands;
use Drupal\config_auto_export\Service;
use Drupal\Core\Config\CachedStorage;
......@@ -9,12 +9,15 @@ use Drupal\Core\Config\FileStorage;
use Drupal\Core\Diff\DiffFormatter;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drush\Attributes as CLI;
use Drush\Commands\DrushCommands;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* A Drush commandfile.
*/
class ConfigAutoExportCommands extends DrushCommands {
use StringTranslationTrait;
/**
......@@ -75,7 +78,14 @@ class ConfigAutoExportCommands extends DrushCommands {
* @param \Drupal\Core\Render\RendererInterface $renderer
* The interface for the renderer.
*/
public function __construct(ConfigManagerInterface $configManager, DiffFormatter $diffFormatter, CachedStorage $cachedStorage, FileStorage $fileStorage, Service $service, RendererInterface $renderer) {
public function __construct(
ConfigManagerInterface $configManager,
DiffFormatter $diffFormatter,
CachedStorage $cachedStorage,
FileStorage $fileStorage,
Service $service,
RendererInterface $renderer
) {
parent::__construct();
$this->configManager = $configManager;
$this->diffFormatter = $diffFormatter;
......@@ -86,10 +96,30 @@ class ConfigAutoExportCommands extends DrushCommands {
}
/**
* Trigger config auto export.
* Return an instance of these Drush commands.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The container.
*
* @command cae:trigger
* @return \Drupal\config_auto_export\Drush\Commands\ConfigAutoExportCommands
* The instance of Drush commands.
*/
public static function create(ContainerInterface $container): ConfigAutoExportCommands {
return new ConfigAutoExportCommands(
$container->get('config.manager'),
$container->get('diff.formatter'),
$container->get('config.storage'),
$container->get('config_auto_export.storage'),
$container->get('config_auto_export.service'),
$container->get('renderer'),
);
}
/**
* Trigger config auto export.
*/
#[CLI\Command(name: 'cae:trigger', aliases: [])]
#[CLI\Usage(name: 'cae:trigger', description: 'Trigger config auto export.')]
public function trigger(): void {
if ($this->service->triggerExport()) {
$this->io()->success('Successfully triggered config export.');
......@@ -101,9 +131,9 @@ class ConfigAutoExportCommands extends DrushCommands {
/**
* Get status of config auto export.
*
* @command cae:status
*/
#[CLI\Command(name: 'cae:status', aliases: [])]
#[CLI\Usage(name: 'cae:status', description: 'Get status of config auto export.')]
public function status(): void {
if ($this->service->isPaused()) {
$this->io()->warning('Config auto export is paused.');
......@@ -115,9 +145,9 @@ class ConfigAutoExportCommands extends DrushCommands {
/**
* Pause config auto export.
*
* @command cae:pause
*/
#[CLI\Command(name: 'cae:pause', aliases: [])]
#[CLI\Usage(name: 'cae:pause', description: 'Pause config auto export.')]
public function pause(): void {
$this->service->pause();
$this->io()->success('Config auto export paused.');
......@@ -125,9 +155,9 @@ class ConfigAutoExportCommands extends DrushCommands {
/**
* Resume config auto export.
*
* @command cae:resume
*/
#[CLI\Command(name: 'cae:resume', aliases: [])]
#[CLI\Usage(name: 'cae:resume', description: 'Resume config auto export.')]
public function resume(): void {
$this->service->resume();
$this->io()->success('Config auto export resumed.');
......@@ -135,9 +165,9 @@ class ConfigAutoExportCommands extends DrushCommands {
/**
* Re-import config auto export.
*
* @command cae:re-import
*/
#[CLI\Command(name: 'cae:re-import', aliases: [])]
#[CLI\Usage(name: 'cae:re-import', description: 'Re-import config auto export.')]
public function reImport(): void {
$diffs = [];
$this->diffFormatter->show_header = FALSE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment