Skip to content

Commit

Permalink
updates validate/init hooks for AcquiaCommand to allow query options.
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 9, 2020
1 parent d9e5b56 commit d8ca6d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
32 changes: 16 additions & 16 deletions src/Commands/AcquiaCommand.php
Expand Up @@ -83,22 +83,21 @@ protected function confirm($question, $default = false)
}

/**
* Adds sort, limit, and filer options to the CloudAPI request.
* Adds sort, limit, and filter options to the CloudAPI request.
*
* @hook init
* @hook validate
*
* @param InputInterface $input
* @param AnnotationData $annotationData
* @param CommandData $commandData
*/
public function initApiOptionsHook(InputInterface $input, AnnotationData $annotationData)
public function validateApiOptionsHook(CommandData $commandData)
{
if ($limit = $input->getOption('limit')) {
if ($limit = $commandData->input()->getOption('limit')) {
$this->cloudapi->addQuery('limit', $limit);
}
if ($sort = $input->getOption('sort')) {
if ($sort = $commandData->input()->getOption('sort')) {
$this->cloudapi->addQuery('sort', $sort);
}
if ($filter = $input->getOption('filter')) {
if ($filter = $commandData->input()->getOption('filter')) {
$this->cloudapi->addQuery('filter', $filter);
}
}
Expand All @@ -107,11 +106,12 @@ public function initApiOptionsHook(InputInterface $input, AnnotationData $annota
* Replace application names and environment names with UUIDs before
* commands run.
*
* @hook validate
* @hook init
*
* @param CommandData $commandData
* @param InputInterface $input
* @param AnnotationData $annotationData
*/
public function validateUuidHook(CommandData $commandData)
public function initUuidHook(InputInterface $input, AnnotationData $annotationData)
{

// Not super ideal to use this, however this is required until I can work
Expand All @@ -128,21 +128,21 @@ public function validateUuidHook(CommandData $commandData)
return;
}

if ($commandData->input()->hasArgument('uuid')) {
$uuid = $commandData->input()->getArgument('uuid');
if ($input->hasArgument('uuid')) {
$uuid = $input->getArgument('uuid');

// Detect if a UUID has been passed in or a sitename.
if (!preg_match(self::UUIDV4, $uuid)) {
// Detect if this is not a fully qualified Acquia sitename e.g. prod:acquia
if (strpos($uuid, ':') === false) {
// Use a realm passed in from the command line e.g. --realm=devcloud.
// If no realm is specified, 'prod:' will be prepended by default.
if ($commandData->input()->hasOption('realm')) {
$uuid = $commandData->input()->getOption('realm') . ':' . $uuid;
if ($input->hasOption('realm')) {
$uuid = $input->getOption('realm') . ':' . $uuid;
}
}
$uuid = $this->cloudapiService->getApplicationUuid($uuid);
$commandData->input()->setArgument('uuid', $uuid);
$input->setArgument('uuid', $uuid);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Commands/SshCommand.php
Expand Up @@ -24,13 +24,13 @@ class SshCommand extends EnvironmentsCommand
public function sshInfo(Client $client, Environments $environmentsAdapter, $uuid, $env = null)
{

if (null !== $env) {
$client->addQuery('filter', "name=${env}");
}
// if (null !== $env) {
// $client->addQuery('filter', "name=${env}");
// }

$environments = $environmentsAdapter->getAll($uuid);

$client->clearQuery();
// $client->clearQuery();

foreach ($environments as $e) {
/** @var $e EnvironmentResponse */
Expand Down

0 comments on commit d8ca6d5

Please sign in to comment.