Skip to content
Open
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
10 changes: 10 additions & 0 deletions src/terra/Command/Environment/EnvironmentEnable.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('<error>Unable to save drush alias.</error>');
}

// Write Drupal Console site targets.
$console_target_file_path = "{$_SERVER['HOME']}/.console/sites/terra.{$app_name}.yml";
if ($environment_factory->writeConsoleSiteTargets()) {
$output->writeln("<info>Drupal Console site file created at {$console_target_file_path}</info>");
$output->writeln("Wrote Drupal Console site file to <comment>$console_target_file_path</comment>");
$output->writeln("Use <info>drupal {$environment_factory->getDrushAlias()}</info> to access the site.");
} else {
$output->writeln('<error>Unable to save Drupal Console site target.</error>');
}

// Run the enable hooks
$output->writeln('');
$output->writeln('Running <comment>ENABLE</comment> app hook...');
Expand Down
33 changes: 33 additions & 0 deletions src/terra/Factory/EnvironmentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,39 @@ public function writeDrushAlias()
}
}

/**
* Writes a local Drupal Console site file.
*/
public function writeConsoleSiteTargets()
{
$console_target_file_path = "{$_SERVER['HOME']}/.console/sites/terra.{$this->app->name}.yml";

$console_target_file = array();
$console_target_file[] = '';

foreach ($this->app->environments as $environment_name => $environment) {
$factory = new self($environment, $this->app);
$path = "/source/" . $environment['document_root'];
$console_target_file[] = '# DO NOT EDIT. This is generated by Terra. Any changes will be overridden when the environment is re-enabled.';
$console_target_file[] = "{$environment_name}:";
$console_target_file[] = " host: {$factory->getHost()}";
$console_target_file[] = " root: $path";
$console_target_file[] = " user: root";
$console_target_file[] = " port: {$factory->getDrushPort()}";
$console_target_file[] = '';
}

$fs = new FileSystem();

try {
$fs->dumpFile($console_target_file_path, implode("\n", $console_target_file));

return true;
} catch (IOException $e) {
return false;
}
}

/**
* Get the name of the drush alias.
*/
Expand Down