Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generate:site:alias] Add new command. #282

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ services:
class: Drupal\Console\Core\Utils\CountCodeLines
console.message_manager:
class: Drupal\Console\Core\Utils\MessageManager
console.drupal_finder:
class: Drupal\Console\Core\Utils\DrupalFinder
# DrupalConsoleCore Commands
console.about:
class: Drupal\Console\Core\Command\AboutCommand
Expand Down Expand Up @@ -88,13 +90,22 @@ services:
arguments: ['@console.configuration_manager']
tags:
- { name: drupal.command }
console.drush:
class: Drupal\Console\Core\Command\DrushCommand
arguments: ['@console.configuration_manager', '@console.chain_queue']
tags:
- { name: drupal.command }
console.generate_site_alias:
class: Drupal\Console\Core\Command\Generate\SiteAliasCommand
arguments: ['@console.site_alias_generator', '@console.configuration_manager', '@console.drupal_finder']
tags:
- { name: drupal.command }
# DrupalConsoleCore Generators
console.init_generator:
class: Drupal\Console\Core\Generator\InitGenerator
tags:
- { name: drupal.generator }
console.drush:
class: Drupal\Console\Core\Command\DrushCommand
arguments: ['@console.configuration_manager', '@console.chain_queue']
console.site_alias_generator:
class: Drupal\Console\Core\Generator\SiteAliasGenerator
tags:
- { name: drupal.command }
- { name: drupal.generator }
10 changes: 8 additions & 2 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public function doRun(InputInterface $input, OutputInterface $output)
if (in_array($this->commandName, $namespaces)) {
$input = new ArrayInput(
[
'command' => 'list',
'namespace' => $this->commandName
'command' => 'list',
'namespace' => $this->commandName
]
);
$this->commandName = 'list';
Expand Down Expand Up @@ -480,6 +480,12 @@ private function registerGenerators()
$this->container->get('console.count_code_lines')
);
}

if (method_exists($generator, 'setDrupalFinder')) {
$generator->setDrupalFinder(
$this->container->get('console.drupal_finder')
);
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Command/Chain/ChainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$parser = new Parser();
$configData = $parser->parse($chainContent);
$chainData = $parser->parse($chainContent);

$commands = [];
if (array_key_exists('commands', $configData)) {
$commands = $configData['commands'];
if (array_key_exists('commands', $chainData)) {
$commands = $chainData['commands'];
}

$chainInlineOptions = $input->getOptions();
Expand Down
25 changes: 16 additions & 9 deletions src/Command/Debug/SiteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,30 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);

$sites = array_keys($this->configurationManager->getSites());
$sites = $this->configurationManager->getSites();

if (!$sites) {
$io->error($this->trans('commands.debug.site.messages.invalid-sites'));

return 1;
}


// --target argument
$target = $input->getArgument('target');
if (!$target) {
$tableHeader =[
$this->trans('commands.debug.site.messages.site'),
];

$io->table($tableHeader, $sites);
foreach ($sites as $key => $site) {
$environments = array_keys($site);
unset($environments[0]);

$environments = array_map(
function ($element) use ($key) {
return $key . '.' . $element;
},
$environments
);

$io->info($key);
$io->listing($environments);
}

return 0;
}
Expand Down Expand Up @@ -114,7 +121,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$io->info($target);
$dumper = new Dumper();
$io->writeln($dumper->dump($targetConfig, 2));
$io->writeln($dumper->dump($targetConfig, 4, 2));

return 0;
}
Expand Down
Loading