示例#1
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");
 }
示例#2
0
文件: DQL.php 项目: fousheezy/common
 /**
  * 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;
 }
示例#3
0
文件: Base.php 项目: fousheezy/common
 /**
  * Returns whether, based on the Param values
  * the
  * @param  Params $params
  * @return bool
  */
 protected function isSingular(Params $params)
 {
     return $params->has($this->getIdParam());
 }