app/library/Acl.php: use the new Acl api in phalcon.
This commit is contained in:
parent
1867351716
commit
61bd9eb692
1 changed files with 10 additions and 6 deletions
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue