isAllowed() 공개 메소드

Determine if current rule allows access
public isAllowed ( ) : boolean
리턴 boolean
예제 #1
0
 public function testCanSetAndCheckRestrictionAgainstConditions()
 {
     $object1 = new stdClass();
     $object1->id = 1;
     $object2 = new stdClass();
     $object2->id = 2;
     $rule = new Rule(false, 'read', 'stdClass', function ($obj) {
         return $obj->id == 1;
     });
     $this->assertFalse($rule->isAllowed($object1));
     $this->assertTrue($rule->isAllowed($object2));
     $rule->when(function ($obj) {
         return 1 == 2;
     });
     $this->assertFalse($rule->isAllowed($object1));
     $this->assertTrue($rule->isAllowed($object2));
     $rule->when(function ($obj) {
         return 1 == 1;
     });
     $this->assertFalse($rule->isAllowed($object1));
     $this->assertFalse($rule->isAllowed($object2));
 }