Пример #1
0
 /**
  * @return $this
  */
 protected function _prepareCollection()
 {
     $collection = $this->_userRolesFactory->create();
     $collection->setRolesFilter();
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Пример #2
0
 /**
  * Identify user role from user identifier.
  *
  * @param UserIdentifier $userIdentifier
  * @return Role|false Return false in case when no role associated with provided user was found.
  * @throws \LogicException
  */
 protected function _getUserRole($userIdentifier)
 {
     if (!$this->_canRoleBeCreatedForUserType($userIdentifier)) {
         throw new \LogicException("The role with user type '{$userIdentifier->getUserType()}' does not exist and cannot be created");
     }
     $roleCollection = $this->_roleCollectionFactory->create();
     $userType = $userIdentifier->getUserType();
     /** @var Role $role */
     $userId = $userIdentifier->getUserId();
     $role = $roleCollection->setUserFilter($userId, $userType)->getFirstItem();
     return $role->getId() ? $role : false;
 }