ZF-2289: Multiple Assertions

Issue Type: Improvement Created: 2007-12-10T05:05:31.000+0000 Last Updated: 2008-03-21T16:25:37.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Marcos Gil Fuertes (marcis) Assignee: Darby Felton (darby) Tags: - Zend_Acl

Related issues: Attachments:


I think it would be interesting if it was possible to assign more than one assertion in the allow and deny methods (4th parameter). Or maybe a new method to add more assertions...

Of course you can implement a new Zend_Acl_Assert_Interface class calling multiple asserts, but it's boring.



Posted by Darby Felton (darby) on 2007-12-10T12:30:11.000+0000

I think that the proper solution is, as you suggested, to implement the assertion method... however you want, including assertion chains. This is actually quite trivial to do, and I don't see a compelling need to bloat the API with this. If you disagree, please feel free to reopen the issue with more feedback. Thank you! :)

Posted by Marcos Gil Fuertes (marcis) on 2007-12-12T06:35:59.000+0000

OK, thanks.

I was implementing a new class (calling multiple asserts) for each combination of asserts in the application. Now, I realized it can be done by implementing a generic 'MultiAssert' class like this:

<pre class="highlight"> 
class MultiAssert implements Zend_Acl_Assert_Interface {

    protected $_asserts;

    public function __construct(array $asserts) {
        foreach ($asserts as $assert) {
            $this->_asserts[] = new $assert();

    public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null,
                           Zend_Acl_Resource_Interface $resource = null, $privilege = null) {
        $result = TRUE;
        foreach ($this->_asserts as $assert) {
            $result &= $assert->assert($acl, $role, $resource, $privilege);
        return $result ;

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.