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 ([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;
}