Пример #1
0
 /**
  * @param  Param                                $params
  * @return \FzyCommon\Entity\BaseInterface
  * @throws \FzyCommon\Exception\Search\NotFound
  */
 public function identitySearch(Params $params)
 {
     if ($params->get($this->getIdParam()) == null) {
         throw new NotFound('Unable to locate this entity');
     }
     return $this->find($params->get($this->getIdParam()));
 }
Пример #2
0
 /**
  * @param  Params                          $params
  * @param  Form                            $form
  * @param  \FzyAuth\Service\Password\Reset $reset
  * @return \Zend\Http\Response|ViewModel
  */
 protected function preReset(Params $params, Form $form, \FzyAuth\Service\Password\Reset $reset)
 {
     if (!trim($params->get('token')) || $reset->getUserByToken($params->get('token'))->isNull()) {
         return $this->redirect()->toRoute(UserController::ROUTE_LOGIN);
     }
     $form->setData($params->get());
     $view = new ViewModel(array('changePasswordForm' => $form));
     $view->setTemplate('fzy-auth/password/reset');
     return $view;
 }
Пример #3
0
 /**
  * @param Params $params
  *
  * @return Resource
  * @throws MalformedResourceException
  */
 public static function create(Params $params)
 {
     if ($params->has(static::KEY_RESOURCE)) {
         return new Resource($params->get(static::KEY_RESOURCE), $params->get(static::KEY_PRIVILEGES));
     } elseif ($params->has(static::KEY_CONTROLLER)) {
         return new Resource(AclEnforcerInterface::RESOURCE_CONTROLLER_PREFIX . $params->get(static::KEY_CONTROLLER), $params->get(static::KEY_ACTIONS));
     } elseif ($params->has(static::KEY_ROUTE)) {
         return new Resource(AclEnforcerInterface::RESOURCE_ROUTE_PREFIX . $params->get(static::KEY_ROUTE), $params->get(static::KEY_ACTIONS));
     }
     throw new MalformedResourceException("Invalid ACL resource configuration");
 }
Пример #4
0
 /**
  * @param Params $roleConfig
  *
  * @return ZendAcl
  */
 public function createAcl(Params $roleConfig, ServiceLocatorInterface $sm)
 {
     $acl = new ZendAcl();
     // add all roles from config
     foreach ($roleConfig->get('roles', array()) as $roleName => $roleData) {
         $roleMap = Params::create($roleData);
         $role = new \Zend\Permissions\Acl\Role\GenericRole($roleName);
         $acl->addRole($role, $roleMap->get('inherits', array()));
         // add resources from config
         foreach ($roleMap->get('allow', array()) as $resourceData) {
             $this->addAllowedResource($acl, $role, AclResource::create(Params::create($resourceData)));
         }
         // add denies
         foreach ($roleMap->get('deny', array()) as $resourceData) {
             $this->addDeniedResource($acl, $role, AclResource::create(Params::create($resourceData)));
         }
     }
     // trigger event for post-resource setup
     return $acl;
 }
Пример #5
0
 /**
  * Convenience method to add an AND WHERE IN clause in a common format.
  * If $queryParameterName is unspecified, $requestParameterName is used for both
  *
  * @param  Params       $params
  * @param  QueryBuilder $qb
  * @param $requestParameterName
  * @param  null         $queryParameterName
  * @return $this
  */
 protected function addWhereInFilter(Params $params, QueryBuilder $qb, $requestParameterName, $queryParameterName = null)
 {
     if ($queryParameterName === null) {
         $queryParameterName = $requestParameterName;
     }
     if ($params->has($requestParameterName)) {
         $qb->andWhere($qb->expr()->in($this->alias($queryParameterName), ':' . $requestParameterName))->setParameter($requestParameterName, $params->get($requestParameterName));
     }
     return $this;
 }