Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $assertAllow = new TestAssertion(true);
- $assertDeny = new TestAssertion(false);
- $acl = new Acl();
- $acl->addRole('staff');
- $acl->addResource('base');
- $acl->allow('staff', 'base', 'update', $assertAllow);
- $acl->addResource('user', 'base');
- $acl->allow('staff', 'user', 'update', $assertDeny);
- var_dump($acl->isAllowed('staff', 'user', 'update'));
- class TestAssertion implements AssertionInterface
- {
- protected $value;
- public function __construct($value)
- {
- $this->value = $value;
- }
- public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
- {
- return $this->value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment