-- benoit <[email protected]> wrote
(on Thursday, 03 March 2011, 03:06 AM -0800):
> Why Zend Acl has no constructor ?
> We can set acl rules in any config file (e.g ini file) and pass it to acl's
> contructor.
> Is there a particular reason that Zend_Acl has no constructor ?
At the time Zend_Acl was created, usage of configuration with components
was limited. Since then, there have been no issue requests to introduce
configurability to Zend_Acl.
Typically, I recommend extending Zend_Acl and defining your ACLs in the
constructor:
class Application_Acl extends Zend_Acl
{
public function __construct()
{
$this->addRole('guest')
->addRole('user', 'guest')
->addRole('admin', 'user');
$this->addResource('blog');
$this->allow('blog', 'guest', array('read', 'published'))
->allow('blog', 'user', array('unpublished', 'comment'))
->allow('blog', 'admin', array('write');
}
}
I do think configurability makes sense, however, and want to target it
for ZF2.
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc