Skip to content

Commit

Permalink
Adds in results of phpcbf
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 21, 2020
1 parent bf2c668 commit a06d83e
Show file tree
Hide file tree
Showing 26 changed files with 456 additions and 293 deletions.
12 changes: 8 additions & 4 deletions src/Cli/AcquiaCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

/**
* Class AcquiaCli
*
* @package AcquiaCli
*/
class AcquiaCli
Expand All @@ -31,6 +32,7 @@ class AcquiaCli

/**
* AcquiaCli constructor.
*
* @param Config $config
* @param InputInterface|null $input
* @param OutputInterface|null $output
Expand All @@ -52,7 +54,8 @@ public function __construct(

$application = new Application(self::NAME, $version);

$application->getDefinition()->addOptions([
$application->getDefinition()->addOptions(
[
new InputOption(
'--no-wait',
null,
Expand Down Expand Up @@ -95,7 +98,8 @@ public function __construct(
The order of the fields is significant. A leading - in the field indicates
the field should be sorted in a descending order. Not all fields are sortable.'
),
]);
]
);

// Create and configure container.
$container = $this->getContainer($input, $output, $application, $config, $client);
Expand Down Expand Up @@ -149,8 +153,8 @@ public function injectParameters($container)
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
public function run(InputInterface $input, OutputInterface $output)
Expand Down
19 changes: 12 additions & 7 deletions src/Cli/CloudApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/**
* Class CloudApi
*
* @package AcquiaCli
*/
class CloudApi
Expand All @@ -39,18 +40,22 @@ public static function createClient(Config $config)
$acquia['secret'] = getenv('ACQUIACLI_SECRET');
}

$connector = new Connector([
$connector = new Connector(
[
'key' => $acquia['key'],
'secret' => $acquia['secret'],
]);
/** @var \AcquiaCloudApi\Connector\Client $cloudapi */
]
);
/**
* @var \AcquiaCloudApi\Connector\Client $cloudapi
*/
$client = Client::factory($connector);

return $client;
}

/**
* @param string $name
* @param string $name
* @return mixed
* @throws \Exception
*/
Expand All @@ -68,8 +73,8 @@ public function getApplicationUuid($name)
}

/**
* @param string $uuid
* @param string $environment
* @param string $uuid
* @param string $environment
* @return EnvironmentResponse
* @throws \Exception
*/
Expand All @@ -88,7 +93,7 @@ public function getEnvironment($uuid, $environment)
}

/**
* @param string $organizationName
* @param string $organizationName
* @return OrganizationResponse
* @throws \Exception
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Cli/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* Class Config
*
* @package AcquiaCli
*/
class Config extends RoboConfig implements GlobalOptionDefaultValuesInterface
Expand All @@ -23,7 +24,7 @@ public function __construct($root)
$globalConfig = getenv('HOME') . '/.acquiacli/acquiacli.yml';
$projectConfig = $root . '/acquiacli.yml';

$processor->extend($loader->load(dirname(dirname(__DIR__)) . '/default.acquiacli.yml'));
$processor->extend($loader->load($root . '/default.acquiacli.yml'));
$processor->extend($loader->load($globalConfig));
$processor->extend($loader->load($projectConfig));

Expand Down
1 change: 1 addition & 0 deletions src/Commands/AccountCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Class AccountCommand
*
* @package AcquiaCli\Commands
*/
class AccountCommand extends AcquiaCommand
Expand Down
49 changes: 29 additions & 20 deletions src/Commands/AcquiaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace AcquiaCli\Commands;

use AcquiaCloudApi\Endpoints\Environments;
use AcquiaCloudApi\Endpoints\Notifications;
use AcquiaCloudApi\Endpoints\Databases;
use AcquiaCloudApi\Endpoints\DatabaseBackups;
Expand All @@ -20,32 +21,47 @@

/**
* Class AcquiaCommand
*
* @package AcquiaCli\Commands
*/
abstract class AcquiaCommand extends Tasks
{
// @TODO https://github.com/boedah/robo-drush/issues/18
//use \Boedah\Robo\Task\Drush\loadTasks;

/** @var \AcquiaCli\Cli\CloudApi $cloudapiService */
/**
* @var \AcquiaCli\Cli\CloudApi $cloudapiService
*/
protected $cloudapiService;

/** @var \AcquiaCloudApi\Connector\Client $cloudapi */
/**
* @var \AcquiaCloudApi\Connector\Client $cloudapi
*/
protected $cloudapi;

/** Regex for a valid UUID string. */
/**
* Regex for a valid UUID string.
*/
const UUIDV4 = '/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i';

/** Task response from API indicates failure. */
/**
* Task response from API indicates failure.
*/
const TASKFAILED = 'failed';

/** Task response from API indicates completion. */
/**
* Task response from API indicates completion.
*/
const TASKCOMPLETED = 'completed';

/** Task response from API indicates started. */
/**
* Task response from API indicates started.
*/
const TASKSTARTED = 'started';

/** Task response from API indicates in progress. */
/**
* Task response from API indicates in progress.
*/
const TASKINPROGRESS = 'in-progress';

/**
Expand Down Expand Up @@ -82,7 +98,7 @@ public function getApplications()
* confirmation.
*
* @param string $question
* @param bool $default
* @param bool $default
*/
protected function confirm($question, $default = false)
{
Expand Down Expand Up @@ -150,7 +166,7 @@ public function initUuidHook(InputInterface $input, AnnotationData $annotationDa
/**
* Waits for a notification to complete.
*
* @param OperationResponse $response
* @param OperationResponse $response
* @throws \Exception
*/
protected function waitForNotification($response)
Expand Down Expand Up @@ -194,9 +210,9 @@ protected function waitForNotification($response)
case self::TASKFAILED:
// If there's one failure we should throw an exception
throw new \Exception('Acquia task failed.');
break(2);
// If tasks are started or in progress, we should continue back
// to the top of the loop and wait until tasks are complete.
break(2);
// If tasks are started or in progress, we should continue back
// to the top of the loop and wait until tasks are complete.
case self::TASKSTARTED:
case self::TASKINPROGRESS:
break;
Expand All @@ -205,7 +221,7 @@ protected function waitForNotification($response)
break(2);
default:
throw new \Exception('Unknown notification status.');
break(2);
break(2);
}

// Timeout if the command exceeds the configured timeout threshold.
Expand Down Expand Up @@ -264,14 +280,8 @@ protected function backupAndMoveDbs($uuid, $environmentFrom, $environmentTo, $db
*/
protected function backupAllEnvironmentDbs($uuid, $environment)
{
<<<<<<< HEAD
$dbAdapter = new Databases($this->getCloudApi());
=======
$dbAdapter = new Databases($this->cloudapi);
// var_dump($dbAdapter);
>>>>>>> Various updates to the code and more tests.
$databases = $dbAdapter->getAll($uuid);
// var_dump($databases);
foreach ($databases as $database) {
$this->backupDb($uuid, $environment, $database);
}
Expand All @@ -284,7 +294,6 @@ protected function backupAllEnvironmentDbs($uuid, $environment)
*/
protected function backupDb($uuid, $environment, $database)
{
// var_dump($database);
// Run database backups.
$this->say(sprintf('Backing up DB (%s) on %s', $database->name, $environment->label));
$dbAdapter = new DatabaseBackups($this->getCloudApi());
Expand Down
42 changes: 27 additions & 15 deletions src/Commands/ApplicationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/**
* Class ApplicationsCommand
*
* @package AcquiaCli\Commands
*/
class ApplicationsCommand extends AcquiaCommand
Expand All @@ -33,13 +34,15 @@ public function applications(Applications $applicationsAdapter)
$table->setHeaders(['Name', 'UUID', 'Hosting ID']);
foreach ($applications as $application) {
$table
->addRows([
->addRows(
[
[
$application->name,
$application->uuid,
$application->hosting->id,
],
]);
]
);
}
$table->render();
}
Expand All @@ -65,12 +68,17 @@ public function applicationInfo(

$databases = $databasesAdapter->getAll($uuid);

$dbNames = array_map(function ($database) {
return $database->name;
}, $databases->getArrayCopy());
$dbNames = array_map(
function ($database) {
return $database->name;
},
$databases->getArrayCopy()
);

foreach ($environments as $environment) {
/** @var EnvironmentResponse $environment */
/**
* @var EnvironmentResponse $environment
*/

$environmentName = sprintf('%s (%s)', $environment->label, $environment->name);
if ($environment->flags->livedev) {
Expand All @@ -82,15 +90,17 @@ public function applicationInfo(
}

$table
->addRows([
->addRows(
[
[
$environmentName,
$environment->uuid,
$environment->vcs->path,
implode("\n", $environment->domains),
implode("\n", $dbNames)
],
]);
]
);
}
$table->render();

Expand All @@ -117,22 +127,24 @@ public function applicationsTags(OutputInterface $output, Applications $applicat
$table->setHeaders(['Name', 'Color']);
foreach ($tags as $tag) {
$table
->addRows([
->addRows(
[
[
$tag->name,
$tag->color,
],
]);
]
);
}
$table->render();
}

/**
* Creates an application tag.
*
* @param string $uuid
* @param string $name
* @param string $color
* @param string $uuid
* @param string $name
* @param string $color
*
* @command application:tag:create
* @aliases app:tag:create
Expand All @@ -147,8 +159,8 @@ public function applicationTagCreate(Applications $applicationsAdapter, $uuid, $
/**
* Deletes an application tag.
*
* @param string $uuid
* @param string $name
* @param string $uuid
* @param string $name
*
* @command application:tag:delete
* @aliases app:tag:delete
Expand Down
Loading

0 comments on commit a06d83e

Please sign in to comment.