diff --git a/src/Command/CommandBase.php b/src/Command/CommandBase.php index befa25f84..691a7c5c1 100644 --- a/src/Command/CommandBase.php +++ b/src/Command/CommandBase.php @@ -672,7 +672,7 @@ protected function determineCloudApplication(bool $promptLinkApp = FALSE): ?stri return $applicationUuid; } - protected function doDetermineCloudApplication(): mixed { + protected function doDetermineCloudApplication(): ?string { $acquiaCloudClient = $this->cloudApiClientService->getClient(); if ($this->input->hasArgument('applicationUuid') && $this->input->getArgument('applicationUuid')) { @@ -680,6 +680,12 @@ protected function doDetermineCloudApplication(): mixed { return self::validateUuid($cloudApplicationUuid); } + if ($this->input->hasArgument('environmentId') && $this->input->getArgument('environmentId')) { + $environmentId = $this->input->getArgument('environmentId'); + $environment = $this->getCloudEnvironment($environmentId); + return $environment->application->uuid; + } + // Try local project info. if ($applicationUuid = $this->getCloudUuidFromDatastore()) { $this->logger->debug("Using Cloud application UUID: $applicationUuid from {$this->datastoreAcli->filepath}"); @@ -745,14 +751,14 @@ private function saveCloudUuidToDatastore(ApplicationResponse $application): boo return TRUE; } - protected function getCloudUuidFromDatastore(): mixed { + protected function getCloudUuidFromDatastore(): ?string { return $this->datastoreAcli->get('cloud_app_uuid'); } private function promptLinkApplication( - ?ApplicationResponse $cloudApplication + ApplicationResponse $cloudApplication ): bool { - $answer = $this->io->confirm("Would you like to link the Cloud application {$cloudApplication->name} to this repository?"); + $answer = $this->io->confirm("Would you like to link the Cloud application $cloudApplication->name to this repository?"); if ($answer) { return $this->saveCloudUuidToDatastore($cloudApplication); } @@ -778,10 +784,8 @@ public static function isAcquiaCloudIde(): bool { * Get the Cloud Application UUID from a Cloud IDE's environmental variable. * * This command assumes it is being run inside a Cloud IDE. - * - * @return array|false|string */ - protected static function getThisCloudIdeCloudAppUuid(): bool|array|string { + protected static function getThisCloudIdeCloudAppUuid(): false|string { return getenv('ACQUIA_APPLICATION_UUID'); }