/** * List site organizations * * ## OPTIONS * * <list|add|remove> * : subfunction to run * * [--site=<site>] * : Site's name * * [--org=<name|id>] * : Organization to add/remove from membership, name or UUID * * [--role=<role>] * : Max role for organization on this site ... default "team_member" * */ public function organizations($args, $assoc_args) { $action = array_shift($args); $site = $this->sites->get(Input::siteName(array('args' => $assoc_args))); $data = array(); switch ($action) { case 'add': $role = Input::optional(array('key' => 'role', 'choices' => $assoc_args, 'default' => 'team_member')); $org = Input::orgName(array('args' => $assoc_args)); if (!$this->isOrgAccessible($org)) { $this->failure("Organization is either invalid or you are not a member."); } $workflow = $site->org_memberships->addMember($org, $role); $workflow->wait(); break; case 'remove': $org = Input::orgId(array('args' => $assoc_args)); if (!$this->isOrgAccessible($org)) { $this->failure("Organization is either invalid or you are not a member."); } $member = $site->org_memberships->get($org); if ($member == null) { $this->failure('{org} is not a member of {site}', array('org' => $org, 'site' => $site->get('name'))); } $workflow = $member->removeMember('organization', $org); $workflow->wait(); break; case 'list': default: $orgs = $site->org_memberships->all(); if (empty($orgs)) { $this->log()->warning('No organizations'); } foreach ($orgs as $org) { $org_data = $org->get('organization'); $data[] = array('label' => $org_data->profile->name, 'name' => $org_data->profile->machine_name, 'role' => $org->get('role'), 'id' => $org->get('organization_id')); } $this->output()->outputRecordList($data); break; } if (isset($workflow)) { $this->workflowOutput($workflow); } }
/** * @vcr input_helper_org_helpers */ function testOrgNameAcceptsUuid() { $args = array('org' => 'd59379eb-0c23-429c-a7bc-ff51e0a960c2'); $org = Input::orgName(compact('args')); $this->assertEquals('Terminus Testing', $org); }