本文整理匯總了PHP中Terminus\Helpers\Input::orgname方法的典型用法代碼示例。如果您正苦於以下問題:PHP Input::orgname方法的具體用法?PHP Input::orgname怎麽用?PHP Input::orgname使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Terminus\Helpers\Input
的用法示例。
在下文中一共展示了Input::orgname方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testOrgHelpers
/**
* @vcr input_helper_org_helpers
*/
function testOrgHelpers()
{
$orglist = Input::orglist();
$this->assertInternalType('array', $orglist);
$this->assertArrayHasKey('-', $orglist);
$this->assertArrayHasKey('d59379eb-0c23-429c-a7bc-ff51e0a960c2', $orglist);
// test normal usage
$args = array('org' => 'Terminus Testing');
$org = Input::orgname($args, 'org');
$this->assertEquals('Terminus Testing', $org);
// test case where an orgid is sent and a name should be returned
$args = array('org' => 'd59379eb-0c23-429c-a7bc-ff51e0a960c2');
$org = Input::orgname($args, 'org');
$this->assertEquals('Terminus Testing', $org);
// test case where an orgid is sent and a name should be returned
$args = array('org' => 'd59379eb-0c23-429c-a7bc-ff51e0a960c2');
$org = Input::orgid($args, 'org');
$this->assertEquals('d59379eb-0c23-429c-a7bc-ff51e0a960c2', $org);
$args = array('org' => 'Terminus Testing');
$org = Input::orgid($args, 'org');
$this->assertEquals('d59379eb-0c23-429c-a7bc-ff51e0a960c2', $org);
}
示例2: organizations
/**
* 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($assoc_args));
$data = array();
switch ($action) {
case 'add':
$role = Input::optional('role', $assoc_args, 'team_member');
$org = Input::orgname($assoc_args, 'org');
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($assoc_args, 'org');
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);
}
}
示例3: organizations
/**
* List site organizations
*
* ## OPTIONS
*
* <list|add|remove>
* : subfunction to run
*
* [--site=<site>]
* : Site's name
*
* [--org=<org>]
* : Organization name
*
* [--role=<role>]
* : Max role for organization on this site ... default "team_member"
*
*/
public function organizations($args, $assoc_args)
{
$action = array_shift($args);
$site = SiteFactory::instance(Input::site($assoc_args));
$data = array();
switch ($action) {
case 'add':
$role = Input::optional('role', $assoc_args, 'team_member');
$org = Input::orgname($assoc_args, 'org');
$workflow = $site->addMembership('organization', $org, $role);
$workflow->wait();
Terminus::success("Organization successfully added");
$orgs = $site->memberships();
break;
case 'remove':
$org = Input::orgid($assoc_args, 'org');
$workflow = $site->removeMembership('organization', $org);
$workflow->wait();
Terminus::success("Organization successfully removed");
$orgs = $site->memberships();
break;
case 'default':
case 'list':
$orgs = $site->memberships();
break;
}
if (empty($orgs)) {
Terminus::error("No organizations");
}
// format the data
foreach ($orgs as $org) {
$data[] = array('label' => "{$org->organization->profile->name}", 'name' => $org->organization->profile->machine_name, 'role' => $org->role, 'id' => $org->organization_id);
}
$this->handleDisplay($data);
}
示例4: organizations
/**
* 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($assoc_args));
$data = array();
switch ($action) {
case 'add':
$role = Input::optional('role', $assoc_args, 'team_member');
$org = Input::orgname($assoc_args, 'org');
$workflow = $site->org_memberships->addMember($org, $role);
$workflow->wait();
break;
case 'remove':
$org = Input::orgid($assoc_args, 'org');
$member = $site->org_memberships->get($org);
if ($member == null) {
Terminus::error($org . ' is not a member of ' . $site->get('name'));
}
$workflow = $member->removeMember('organization', $org);
$workflow->wait();
break;
case 'list':
default:
$orgs = $site->org_memberships->all();
if (empty($orgs)) {
Terminus::error('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->outputter->outputRecordList($data);
break;
}
if (isset($workflow)) {
$this->workflowOutput($workflow);
}
}