本文整理汇总了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);
}
}