當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::getRoles方法代碼示例

本文整理匯總了PHP中App\Model\User::getRoles方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getRoles方法的具體用法?PHP User::getRoles怎麽用?PHP User::getRoles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在App\Model\User的用法示例。


在下文中一共展示了User::getRoles方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 /**
  * Index action method
  *
  * @return void
  */
 public function index($rid = null)
 {
     if (null === $rid || $this->services['acl']->isAllowed($this->sess->user->role, 'users-of-role-' . $rid, 'index')) {
         $deniedRoles = [];
         $resources = $this->services['acl']->getResources();
         foreach ($resources as $name => $resource) {
             if (!$this->services['acl']->isAllowed($this->sess->user->role, $name, 'index')) {
                 $deniedRoles[] = (int) substr($name, strrpos($name, '-') + 1);
             }
         }
         $user = new Model\User();
         $searchUsername = $this->request->getQuery('search_username');
         if ($user->hasPages($this->application->config()['pagination'], $rid, $searchUsername, $deniedRoles)) {
             $limit = $this->application->config()['pagination'];
             $pages = new Paginator($user->getCount($rid, $searchUsername, $deniedRoles), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->prepareView('users/index.phtml');
         $this->view->title = 'Users';
         $this->view->pages = $pages;
         $this->view->roleId = $rid;
         $this->view->queryString = $this->getQueryString('sort');
         $this->view->searchUsername = $searchUsername;
         $this->view->users = $user->getAll($rid, $searchUsername, $deniedRoles, $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
         $this->view->roles = $user->getRoles();
         $this->send();
     } else {
         $this->redirect('/users');
     }
 }
開發者ID:popphp,項目名稱:pop-bootstrap,代碼行數:38,代碼來源:IndexController.php

示例2: updateUser

 /**
  * Sorry this changes will be not persisted.
  *
  * @param User   $user
  * @param string $password
  */
 public function updateUser(User $user, $password)
 {
     $this->database[$user->getName()] = ['password' => $this->encode($password), 'roles' => $user->getRoles()];
 }
開發者ID:desarrolla2,項目名稱:kata1,代碼行數:10,代碼來源:UserRepository.php


注:本文中的App\Model\User::getRoles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。