本文整理汇总了PHP中Terminus\Helpers\Input::role方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::role方法的具体用法?PHP Input::role怎么用?PHP Input::role使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus\Helpers\Input
的用法示例。
在下文中一共展示了Input::role方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRoleFromArgs
function testRoleFromArgs()
{
$args = array('role' => 'admin');
$role = Input::role(compact('args'));
$this->assertEquals('admin', $role);
}
示例2: team
/**
* Get or set team members
*
* ## OPTIONS
*
* <list|add-member|remove-member|change-role>
* : i.e. add or remove
*
* [--site=<site>]
* : Site to check
*
* [--member=<email>]
* : Email of the member to add. Member will receive an invite
*
* [--role=<role>]
* : Role for the new member to act as
*
* @subcommand team
*/
public function team($args, $assoc_args)
{
$action = 'list';
if (!empty($args)) {
$action = array_shift($args);
}
$site = $this->sites->get(Input::sitename($assoc_args));
$data = array();
$team = $site->user_memberships;
switch ($action) {
case 'add-member':
if ((bool) $site->getFeature('change_management')) {
$role = Input::role($assoc_args);
} else {
$role = 'team_member';
}
$workflow = $team->addMember($assoc_args['member'], $role);
$this->workflowOutput($workflow);
break;
case 'remove-member':
$user = $team->get($assoc_args['member']);
if ($user != null) {
$workflow = $user->removeMember($assoc_args['member']);
$this->workflowOutput($workflow);
} else {
$this->failure('"{member}" is not a valid member.', array('member' => $assoc_args['member']));
}
break;
case 'change-role':
if ((bool) $site->getFeature('change_management')) {
$role = Input::role($assoc_args);
$user = $team->get($assoc_args['member']);
if ($user != null) {
$workflow = $user->setRole($role);
$this->workflowOutput($workflow);
} else {
$this->failure('"{member}" is not a valid member.', array('member' => $assoc_args['member']));
}
} else {
$this->failure('This site does not have the authority to conduct this operation.');
}
break;
case 'list':
default:
$user_memberships = $team->all();
foreach ($user_memberships as $uuid => $user_membership) {
$user = $user_membership->get('user');
$data[] = array('First' => $user->profile->firstname, 'Last' => $user->profile->lastname, 'Email' => $user->email, 'UUID' => $user->id);
}
ksort($data);
break;
}
if (!empty($data)) {
$this->output()->outputRecordList($data);
}
}
示例3: team
/**
* Get or set team members
*
* ## OPTIONS
*
* <list|add-member|remove-member|change-role>
* : i.e. add or remove
*
* [--site=<site>]
* : Site to check
*
* [--member=<email>]
* : Email of the member to add. Member will receive an invite
*
* [--role=<role>]
* : Role for the new member to act as
*
* @subcommand team
*/
public function team($args, $assoc_args)
{
$action = array_shift($args) ?: 'list';
$site = SiteFactory::instance(Input::sitename($assoc_args));
$data = array();
$team = $site->getSiteUserMemberships();
switch ($action) {
case 'add-member':
if ((bool) $site->getFeature('change_management')) {
$role = Input::role($assoc_args);
} else {
$role = 'team_member';
}
$workflow = $team->add($assoc_args['member'], $role);
$this->workflowOutput($workflow);
break;
case 'remove-member':
$user = $team->findByEmail($assoc_args['member']);
$workflow = $user->remove($assoc_args['member']);
$this->workflowOutput($workflow);
break;
case 'change-role':
if ((bool) $site->getFeature('change_management')) {
$role = Input::role($assoc_args);
$user = $team->findByEmail($assoc_args['member']);
$workflow = $user->setRole($role);
$this->workflowOutput($workflow);
} else {
Logger::redline('This site does not have the authority to conduct this operation.');
}
break;
case 'list':
default:
$user_memberships = $team->all();
foreach ($user_memberships as $uuid => $user_membership) {
$user = $user_membership->getUser();
$data[] = array('First' => $user->profile->firstname, 'Last' => $user->profile->lastname, 'Email' => $user->email, 'UUID' => $user->id);
}
ksort($data);
break;
}
if (!empty($data)) {
$this->handleDisplay($data);
}
}