Last active
February 28, 2016 20:44
-
-
Save andevsoftware/c10997074ac209085684 to your computer and use it in GitHub Desktop.
Phalcon REST - Create Roles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var \PhalconRest\Acl\MountingEnabledAdapterInterface $acl */ | |
$acl = $di->get(Services::ACL); | |
// These are our main roles | |
$unauthorizedRole = new Acl\Role(AclRoles::UNAUTHORIZED); | |
$authorizedRole = new Acl\Role(AclRoles::AUTHORIZED); | |
// We register them on the acl | |
$acl->addRole($unauthorizedRole); | |
$acl->addRole($authorizedRole); | |
// All the following roles extend either from the authorizedRole or the | |
// unauthorized role. | |
$acl->addRole(new Acl\Role(AclRoles::ADMINISTRATOR), $authorizedRole); | |
$acl->addRole(new Acl\Role(AclRoles::MANAGER), $authorizedRole); | |
$acl->addRole(new Acl\Role(AclRoles::USER), $authorizedRole); | |
// Because the acl we use implements the `MountingEnabledAdapterInterface` | |
// we are allowed to mount our Resources on it. | |
$acl->mountMany($api->getResources()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment