Skip to content

Commit

Permalink
Updates production mode command
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 21, 2020
1 parent 4af9236 commit 92eb62b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Commands/ProductionModeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace AcquiaCli\Commands;

use AcquiaCloudApi\Response\EnvironmentResponse;
use AcquiaCloudApi\Endpoints\Environments;

/**
* Class ProductionModeCommand
Expand All @@ -21,15 +22,14 @@ class ProductionModeCommand extends AcquiaCommand
* @command productionmode:enable
* @alias pm:enable
*/
public function acquiaProductionModeEnable($uuid, EnvironmentResponse $environment)
public function productionModeEnable($uuid, EnvironmentResponse $environment)
{
if ('prod' !== $environment->name) {
throw new \Exception('Production mode may only be enabled/disabled on the prod environment.');
}
$label = $environment->label;
$this->say("Enabling production mode for ${label} environment");
$this->cloudapi->enableProductionMode($environment->uuid);
$this->waitForTask($uuid, 'ProductionModeEnabled');
$this->say(sprintf('Enabling production mode for %s environment', $environment->label));
$environmentAdapter = new Environments($this->cloudapi);
$environmentAdapter->enableProductionMode($environment->uuid);
}

/**
Expand All @@ -42,17 +42,16 @@ public function acquiaProductionModeEnable($uuid, EnvironmentResponse $environme
* @command productionmode:disable
* @alias pm:disable
*/
public function acquiaRemoveDomain($uuid, EnvironmentResponse $environment)
public function productionModeDisable($uuid, EnvironmentResponse $environment)
{
if ('prod' !== $environment->name) {
throw new \Exception('Production mode may only be enabled/disabled on the prod environment.');
}

if ($this->confirm('Are you sure you want to disable production mode?')) {
$label = $environment->label;
$this->say("Disabling production mode for ${label} environment");
$this->cloudapi->disableProductionMode($environment->uuid);
$this->waitForTask($uuid, 'ProductionModeDisabled');
$this->say(sprintf('Disabling production mode for %s environment', $environment->label));
$environmentAdapter = new Environments($this->cloudapi);
$environmentAdapter->disableProductionMode($environment->uuid);
}
}
}

0 comments on commit 92eb62b

Please sign in to comment.