We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Does ACL Role Inheritance Nest Automatically?

I'm basically wondering if a role inherits all the inheritance that the role it inherits from already inherits (I know, a mouthful).

IE: Do I have to explicitly cite all sub-inheritance:

//Restricted User can do everything a Guest can do:
$acl->addInherit('Restricted User','Guest');
// User can do everything a Restricted User can do:
$acl->addInherit('User','Guest');
$acl->addInherit('User','Restricted User');
// Admin can do everything a User and Restricted User and a Guest can do:
$acl->addInherit('Admin','Guest');
$acl->addInherit('Admin','Restricted User');
$acl->addInherit('Admin','User');

Or does it automatically grab nested permissions, like so:

//Restricted User can do everything a Guest can do:
$acl->addInherit('Restricted User','Guest');
// User can do everything a Restricted User can do
$acl->addInherit('User','Restricted User');
// Admin can do everything a User can do
$acl->addInherit('Admin','User');


8.3k
Accepted
answer

Found it in the source:

        /**
         * Deep inherits
         */
        if isset this->_roleInherits[roleInheritName] {
            for deepInheritName in this->_roleInherits[roleInheritName] {
                this->addInherit(roleName, deepInheritName);
            }
        }

Apparently the "deep inheritance" is automatic, so the 2nd set of code should work fine.