当前位置: 首页>>代码示例>>PHP>>正文


PHP Input::role方法代码示例

本文整理汇总了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);
 }
开发者ID:serundeputy,项目名称:cli,代码行数:6,代码来源:test-input-helper.php

示例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);
     }
 }
开发者ID:4aficiona2,项目名称:cli,代码行数:75,代码来源:SiteCommand.php

示例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);
     }
 }
开发者ID:skyywalk3rr,项目名称:cli,代码行数:64,代码来源:site.php


注:本文中的Terminus\Helpers\Input::role方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。