Hi and thanks for replying It's not an error that I've used the registry. I have an already constructed ACL object there.
Your example is identical with mine only that you construct the ACL in place and I get it from a class. But in my case the second return is "true" which is very wrong. Also my object is more complex in terms of resources and roles both with inheritace levels. I read something about assertions breaking when inheritance is used and I think this could be the real problem. Because otherwise I did understand the mechanisms of Assertions. http://framework.zend.com/issues/browse/ZF-1722 http://framework.zend.com/issues/browse/ZF-1722 Martijn Korse wrote: > > Hi valugi<br> > <br> > Let's review your code first<br> > <br> > You're using Zend_Registy in your example, but i'm not sure why. I think > you're confusing it with the Role-Registry? Zend_Registry is a different > thing and not part of Zend_Acl.<br> > Also, you forget to instantiate proper roles and resources (through > Zend_Acl_Role and Zend_Acl_Resource).<br> > <br> > I've rewritten your example:<br> > <br> > <pre> > class My_Acl_Assert_Test implements Zend_Acl_Assert_Interface > { > public function __construct($test) > { > $this->test= $test; > } > > public function assert(Zend_Acl $acl, > Zend_Acl_Role_Interface $role = null, > Zend_Acl_Resource_Interface $resource = null, > $privilege = null) > { > return $this->_test(); > } > > protected function _test() > { > return $this->test; > } > } > > //controller code > $acl = new Zend_Acl(); > $acl->addRole(new Zend_Acl_Role('client')); > $acl->add(new Zend_Acl_Resource('resource')); > $bool = $acl->isAllowed('client', 'resource'); > var_dump($bool); > $assertRule = new My_Acl_Assert_Test( false ); > > // new rules > $acl->allow('client', 'resource', null , $assertRule ); > $bool = $acl->isAllowed('client', 'resource' ); > var_dump($bool); > </pre> > <br> > This outputs the boolean 'false' twice, as expected.<br> > <br> > In case you're still unsure how assertions work: you should see them as a > dependency on the rule. If the assertion returns false it means acl should > ignore the rule. It will then then look if it can find another rule > through inheritance and if no such rule can be found it will return the > default 'false' > <br> > i hope that clears things up for you -- View this message in context: http://www.nabble.com/Zend_Acl_Assert_Interface-Usage-tp19668142p19684326.html Sent from the Zend Framework mailing list archive at Nabble.com.
