本文整理匯總了PHP中Terminus\Helpers\Input::orgId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Input::orgId方法的具體用法?PHP Input::orgId怎麽用?PHP Input::orgId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Terminus\Helpers\Input
的用法示例。
在下文中一共展示了Input::orgId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: tags
/**
* Manage site organization tags
*
* ## OPTIONS
*
* <add|remove|list>
* : subfunction to run
*
* [--site=<site>]
* : Site's name
*
* [--org=<name|id>]
* : Organization to apply tag with
*
* [--tag=<tag>]
* : Tag to add or remove
*
* @subcommand tags
*/
public function tags($args, $assoc_args)
{
$action = array_shift($args);
$site = $this->sites->get(Input::siteName(array('args' => $assoc_args)));
$org = Input::orgId(array('args' => $assoc_args));
if ($site->organizationIsMember($org)) {
switch ($action) {
case 'add':
$tag = Input::string(['args' => $assoc_args, 'key' => 'tag', 'message' => 'Enter a tag to add']);
$response = $site->addTag($tag, $org);
$context = array('tag' => $tag, 'site' => $site->get('name'));
if ($response['status_code'] == 200) {
$this->log()->info('Tag "{tag}" has been added to {site}', $context);
} else {
$this->failure('Tag "{tag}" could not be added to {site}', $context);
}
break;
case 'remove':
$tags = $site->getTags($org);
if (count($tags) === 0) {
$message = 'This organization does not have any tags associated';
$message .= ' with this site.';
$this->failure($message);
} elseif (!isset($assoc_args['tag']) || !in_array($assoc_args['tag'], $tags)) {
$tag = $tags[Input::menu(array('choices' => $tags, 'message' => 'Select a tag to delete'))];
} else {
$tag = $assoc_args['tag'];
}
$response = $site->removeTag($tag, $org);
$context = array('tag' => $tag, 'site' => $site->get('name'));
if ($response['status_code'] == 200) {
$this->log()->info('Tag "{tag}" has been removed from {site}', $context);
} else {
$this->failure('Tag "{tag}" could not be removed from {site}', $context);
}
break;
case 'list':
default:
$tags = $site->getTags($org);
$this->output()->outputRecord(compact('tags'));
break;
}
} else {
$message = '{site} is not a member of an organization,';
$message .= ' which is necessary to associate a tag with a site.';
$this->failure($message, array('site' => $site->get('name')));
}
}
示例2: team
/**
* List an organization's team members
*
* ## OPTIONS
*
* [--org=<id|name>]
* : Organization UUID or name
*
* @subcommand team
*/
public function team($args, $assoc_args)
{
$org_id = Input::orgId(array('args' => $assoc_args, 'allow_none' => false));
$orgs = new UserOrganizationMemberships();
$org = $orgs->get($org_id);
if (is_null($org)) {
$message = 'The organization {org} is either invalid or you haven\'t';
$message .= ' permission sufficient to access its data.';
$this->failure($message, array('org' => $assoc_args['org']));
}
$org_info = $org->get('organization');
$org_model = new Organization($org_info);
$memberships = $org->user_memberships->all();
$data = array();
foreach ($memberships as $membership) {
$member = $membership->get('user');
$first_name = $last_name = null;
if (isset($member->profile->firstname)) {
$first_name = $member->profile->firstname;
}
if (isset($member->profile->lastname)) {
$last_name = $member->profile->lastname;
}
$data[$member->id] = array('first' => $first_name, 'last' => $last_name, 'email' => $member->email, 'uuid' => $member->id);
}
$this->output()->outputRecordList($data);
return $data;
}
示例3: testOrgIdAcceptsName
/**
* @vcr input_helper_org_helpers
*/
function testOrgIdAcceptsName()
{
$args = array('org' => 'Terminus Testing');
$org = Input::orgId(compact('args'));
$this->assertEquals('d59379eb-0c23-429c-a7bc-ff51e0a960c2', $org);
}
示例4: getSiteCreateOptions
/**
* A helper function for getting/prompting for the site create options.
*
* @param array $assoc_args Arguments from command
* @return array
*/
private function getSiteCreateOptions($assoc_args)
{
$options = array();
$options['label'] = Input::string(array('args' => $assoc_args, 'key' => 'label', 'message' => 'Human-readable label for the site'));
$suggested_name = Utils\sanitizeName($options['label']);
if (array_key_exists('name', $assoc_args)) {
// Deprecated but kept for backwards compatibility
$options['name'] = $assoc_args['name'];
} elseif (array_key_exists('site', $assoc_args)) {
$options['name'] = $assoc_args['site'];
} elseif (isset($_SERVER['TERMINUS_SITE'])) {
$options['name'] = $_SERVER['TERMINUS_SITE'];
} else {
$message = 'Machine name of the site; used as part of the default URL';
$message .= " (if left blank will be {$suggested_name})";
$options['name'] = Input::string(array('args' => $assoc_args, 'key' => 'site', 'message' => $message, 'deafult' => $suggested_name));
}
if (isset($assoc_args['org'])) {
$options['organization_id'] = Input::orgId(array('args' => $assoc_args, 'default' => false));
}
return $options;
}