Skip to content

Commit

Permalink
[generate:site:alias] Validate no sites found. (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas committed Feb 12, 2018
1 parent 63b8424 commit 483b8c6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
46 changes: 26 additions & 20 deletions src/Command/Generate/SiteAliasCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,23 @@ protected function interact(
) {
$name = $input->getOption('name');
if (!$name) {
$sites = array_keys($this->configurationManager->getSites());

$name = $this->getIo()->choiceNoList(
$this->trans('commands.generate.site.alias.questions.name'),
$sites,
current($sites),
true
);
$sites = $this->configurationManager->getSites();
if (!empty($sites)) {
$sites = array_keys($this->configurationManager->getSites());
$name = $this->getIo()->choiceNoList(
$this->trans('commands.generate.site.alias.questions.name'),
$sites,
current($sites),
TRUE
);

if (is_numeric($name)) {
$name = $sites[$name];
if (is_numeric($name)) {
$name = $sites[$name];
}
} else {
$name = $this->getIo()->ask(
$this->trans('commands.generate.site.alias.questions.name')
);
}

$input->setOption('name', $name);
Expand Down Expand Up @@ -282,16 +288,16 @@ protected function execute(
) {
$this->generator->generate(
[
'name' => $input->getOption('name'),
'environment' => $input->getOption('environment'),
'type' => $input->getOption('type'),
'extra_options' => $input->getOption('extra-options'),
'root' => $input->getOption('composer-root'),
'uri' => $input->getOption('site-uri'),
'port' => $input->getOption('port'),
'user' => $input->getOption('user'),
'host' => $input->getOption('host'),
'directory' => $input->getOption('directory')
'name' => $input->getOption('name'),
'environment' => $input->getOption('environment'),
'type' => $input->getOption('type'),
'extra_options' => $input->getOption('extra-options'),
'root' => $input->getOption('composer-root'),
'uri' => $input->getOption('site-uri'),
'port' => $input->getOption('port'),
'user' => $input->getOption('user'),
'host' => $input->getOption('host'),
'directory' => $input->getOption('directory')
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/SiteAliasGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SiteAliasGenerator extends Generator
public function generate(array $parameters)
{
$this->renderFile(
'sites/alias.yml.twig',
'core/sites/alias.yml.twig',
$parameters['directory'] . '/sites/' . $parameters['name'] . '.yml',
$parameters,
FILE_APPEND
Expand Down

0 comments on commit 483b8c6

Please sign in to comment.