Archived
1
0
Fork 0

app/library/Acl.php: use the new Acl api in phalcon.

This commit is contained in:
Henrik Hautakoski 2022-07-26 19:59:28 +02:00
parent 1867351716
commit 61bd9eb692

View file

@ -3,6 +3,7 @@
namespace Httpcb;
use Phalcon\Config,
Phalcon\Acl\Enum,
Phalcon\Acl\Role,
Phalcon\Acl\Adapter\Memory as Adapter;
@ -21,7 +22,7 @@ class Acl
$this->_adapter = new Adapter();
// Deny access to everything by default.
$this->_adapter->setDefaultAction(\Phalcon\Acl::DENY);
$this->_adapter->setDefaultAction(Enum::DENY);
$this->fromConfig($config);
}
@ -46,7 +47,7 @@ class Acl
$resource = $wildcard;
}
}
return $this->_adapter->isAllowed($role, $resource, 'All') == \Phalcon\Acl::ALLOW;
return $this->_adapter->isAllowed($role, $resource, 'All') == Enum::ALLOW;
}
/**
@ -55,7 +56,7 @@ class Acl
*/
public function hasResource($resource)
{
return $this->_adapter->isResource($resource);
return $this->_adapter->isComponent($resource);
}
public function fromConfig(Config $config)
@ -84,7 +85,7 @@ class Acl
}
foreach($resources as $resource) {
$this->_adapter->addResource($resource, 'All');
$this->_adapter->addComponent($resource, 'All');
}
}
@ -98,9 +99,12 @@ class Acl
}
foreach($zones as $zone) {
$resources = (array) $config->zones->get($zone);
$resources = $config->zones->get($zone);
if (!($resources instanceof Config)) {
$resources = new Config([ $resources ]);
}
foreach($resources as $resource) {
$this->_adapter->allow($name, $resource, 'All');
$this->_adapter->allow($name, $resource, 'All');
}
}
}