Skip to content

Commit

Permalink
Adds admins to the members view
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 21, 2020
1 parent 6538a18 commit a282fe7
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions src/Commands/OrganizationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use AcquiaCloudApi\Response\OrganizationResponse;
use AcquiaCloudApi\Response\TeamResponse;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Helper\TableCell;
use AcquiaCloudApi\Endpoints\Organizations;

/**
Expand Down Expand Up @@ -52,14 +54,16 @@ public function showOrganizations()
/**
* Shows a list of all applications within an organization.
*
* @param string $organizationUuid
* @param string $organization
*
* @command organization:applications
* @alias org:apps
*/
public function organizationApplications($organizationUuid)
public function organizationApplications($organization)
{
$applications = $this->cloudapi->organizationApplications($organizationUuid);
$organizationUuid = $organization->uuid;
$organizationsAdapter = new Organizations($this->cloudapi);
$applications = $organizationsAdapter->getApplications($organizationUuid);

$this->say("Applications in organisation: ${organizationUuid}");
$table = new Table($this->output());
Expand Down Expand Up @@ -123,17 +127,45 @@ public function members($organization)
{
$organizationUuid = $organization->uuid;
$organizationsAdapter = new Organizations($this->cloudapi);
$admins = $organizationsAdapter->getAdmins($organizationUuid);
$members = $organizationsAdapter->getMembers($organizationUuid);

$this->say("Members in organisation: ${organizationUuid}");
$table = new Table($this->output());
$table->setHeaders(['UUID', 'Username', 'Mail', 'Teams(s)']);
$table
->setHeaders(['UUID', 'Username', 'Mail', 'Teams(s)'])
->setColumnStyle(0, 'center-align')
->setRows([
[new TableCell('Organisation Administrators', ['colspan' => 4])],
new TableSeparator(),
]);

foreach ($admins as $admin) {
/** @var MemberResponse $admin */
$table
->addRows([
[
$admin->uuid,
$admin->username,
$admin->mail,
'admin'
],
]);
}

$table
->addRows([
new TableSeparator(),
[new TableCell('Organisation Members', ['colspan' => 4])],
new TableSeparator(),
]);

foreach ($members as $member) {
$teamList = array_map(function ($team) {
return $team->name;
}, $member->teams->getArrayCopy());
$teamString = implode(',', $teamList);
/** @var MemberResponse $permission */
/** @var MemberResponse $member */
$table
->addRows([
[
Expand Down

0 comments on commit a282fe7

Please sign in to comment.