Exemple #1
0
 /**
  * {@inheritdoc}
  * Example:
  * <code>
  * //Does Andres have access to the customers resource to create?
  * $acl->isAllowed('Andres', 'Products', 'create');
  * //Do guests have access to any resource to edit?
  * $acl->isAllowed('guests', '*', 'edit');
  * </code>
  *
  * @param string $role
  * @param string $resource
  * @param string $access
  *
  * @return bool
  */
 public function isAllowed($role, $resource, $access)
 {
     if ($this->redis->sIsMember("accessList:{$role}:{$resource}:" . Acl::ALLOW, $access)) {
         return Acl::ALLOW;
     }
     if ($this->redis->exists("rolesInherits:{$role}")) {
         $rolesInherits = $this->redis->sMembers("rolesInherits:{$role}");
         foreach ($rolesInherits as $role) {
             if ($this->redis->sIsMember("accessList:{$role}:{$resource}:" . Acl::ALLOW, $access)) {
                 return Acl::ALLOW;
             }
         }
     }
     /**
      * Return the default access action
      */
     return $this->getDefaultAction();
 }