-
-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new commands to process features. (#3021)
- Loading branch information
Showing
4 changed files
with
415 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
feature_debug: | ||
class: Drupal\Console\Command\Features\DebugCommand | ||
tags: | ||
- { name: drupal.command } | ||
feature_import: | ||
class: Drupal\Console\Command\Features\ImportCommand | ||
tags: | ||
- { name: drupal.command } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains \Drupal\Console\Command\Features\DebugCommand. | ||
*/ | ||
|
||
namespace Drupal\Console\Command\Features; | ||
|
||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Drupal\Console\Command\Shared\FeatureTrait; | ||
use Drupal\Console\Command\Shared\CommandTrait; | ||
use Drupal\Console\Style\DrupalStyle; | ||
use Drupal\Console\Annotations\DrupalCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
|
||
|
||
/** | ||
* @DrupalCommand( | ||
* extension = "features", | ||
* extensionType = "module" | ||
* ) | ||
*/ | ||
|
||
class DebugCommand extends Command | ||
{ | ||
use CommandTrait; | ||
use FeatureTrait; | ||
|
||
|
||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure() | ||
{ | ||
$this | ||
->setName('features:debug') | ||
->setDescription($this->trans('commands.features.debug.description')) | ||
->addArgument( | ||
'bundle', | ||
InputArgument::OPTIONAL, | ||
$this->trans('commands.features.debug.arguments.bundle') | ||
); | ||
|
||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$io = new DrupalStyle($input, $output); | ||
$bundle= $input->getArgument('bundle'); | ||
|
||
$tableHeader = [ | ||
$this->trans('commands.features.debug.messages.bundle'), | ||
$this->trans('commands.features.debug.messages.name'), | ||
$this->trans('commands.features.debug.messages.machine_name'), | ||
$this->trans('commands.features.debug.messages.status'), | ||
$this->trans('commands.features.debug.messages.state'), | ||
]; | ||
|
||
$tableRows = []; | ||
|
||
$features = $this->getFeatureList($bundle); | ||
|
||
foreach ($features as $feature) { | ||
$tableRows[] = [$feature['bundle_name'],$feature['name'], $feature['machine_name'], $feature['status'],$feature['state']]; | ||
} | ||
|
||
$io->table($tableHeader, $tableRows, 'compact'); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains \Drupal\Console\Command\Features\ImportCommand. | ||
*/ | ||
|
||
namespace Drupal\Console\Command\Features; | ||
|
||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Drupal\Console\Command\Shared\FeatureTrait; | ||
use Drupal\Console\Command\Shared\CommandTrait; | ||
use Drupal\Console\Style\DrupalStyle; | ||
use Drupal\Console\Annotations\DrupalCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
|
||
|
||
/** | ||
* @DrupalCommand( | ||
* extension = "features_ui", | ||
* extensionType = "module" | ||
* ) | ||
*/ | ||
|
||
class ImportCommand extends Command | ||
{ | ||
use CommandTrait; | ||
use FeatureTrait; | ||
|
||
|
||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure() | ||
{ | ||
$this | ||
->setName('features:import') | ||
->setDescription($this->trans('commands.features.import.description')) | ||
->addOption( | ||
'bundle', | ||
'', | ||
InputOption::VALUE_OPTIONAL, | ||
$this->trans('commands.features.import.options.packages') | ||
) | ||
->addArgument('packages',InputArgument::IS_ARRAY,$this->trans('commands.features.import.arguments.packages')); | ||
|
||
|
||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$io = new DrupalStyle($input, $output); | ||
|
||
$packages = $input->getArgument('packages'); | ||
$bundle = $input->getOption('bundle'); | ||
|
||
if ($bundle) { | ||
$packages = $this->getPackagesByBundle($bundle); | ||
} | ||
|
||
$this->getAssigner($bundle); | ||
$this->importFeature($io,$packages); | ||
|
||
} | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function interact(InputInterface $input, OutputInterface $output) | ||
{ | ||
$io = new DrupalStyle($input, $output); | ||
|
||
$packages = $input->getArgument('packages'); | ||
$bundle = $input->getOption('bundle'); | ||
|
||
if (!$packages && !$bundle) { | ||
// @see Drupal\Console\Command\Shared\FeatureTrait::packageQuestion | ||
$bundle = $this->packageQuestion($io); | ||
$input->setArgument('packages', $bundle); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.