Manages ACL lists in Redis Database
Inheritance: extends Phalcon\Acl\Adapter
Exemplo n.º 1
0
 /**
  * @param $roleName
  * @param $resourceName
  * @param $accessName
  * @param $action
  * @return bool
  * @throws Exception
  */
 protected function setAccess($roleName, $resourceName, $accessName, $action)
 {
     /**
      * Check if the access is valid in the resource
      */
     if ($this->isResourceAccess($resourceName, $accessName)) {
         if (!$this->setNXAccess) {
             throw new Exception("Access '" . $accessName . "' does not exist in resource '" . $resourceName . "' in ACL");
         }
         $this->addResourceAccess($resourceName, $accessName);
     }
     $this->redis->sAdd("accessList:{$roleName}:{$resourceName}:{$action}", $accessName);
     $accessList = "accessList:{$roleName}:{$resourceName}";
     // remove first if exists
     foreach (array(1, 2) as $act) {
         $this->redis->sRem("{$accessList}:{$act}", $accessName);
         $this->redis->sRem("{$accessList}:{$act}", "*");
     }
     $this->redis->sAdd("{$accessList}:{$action}", $accessName);
     $this->redis->sAdd("{$accessList}:{$this->getDefaultAction()}", "*");
     return true;
 }