Guest User

Untitled

a guest
Mar 30th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. $assertAllow = new TestAssertion(true);
  2.         $assertDeny = new TestAssertion(false);
  3.        
  4.         $acl = new Acl();
  5.         $acl->addRole('staff');
  6.         $acl->addResource('base');
  7.         $acl->allow('staff', 'base', 'update', $assertAllow);
  8.        
  9.         $acl->addResource('user', 'base');
  10.         $acl->allow('staff', 'user', 'update', $assertDeny);
  11.        
  12.         var_dump($acl->isAllowed('staff', 'user', 'update'));
  13.  
  14. class TestAssertion implements AssertionInterface
  15. {
  16.     protected $value;
  17.     public function __construct($value)
  18.     {
  19.         $this->value = $value;
  20.     }
  21.    
  22.     public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
  23.     {
  24.         return $this->value;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment