/** * Get permission for given class and method from the ACL annotation * * @param $class * @param $method * @return string */ public function getClassMethodAnnotationPermission($class, $method) { $annotation = $this->annotationProvider->findAnnotation($class, $method); if ($annotation) { return $annotation->getPermission(); } }
public function testFindAndGetAnnotation() { $this->loader->expects($this->once())->method('load')->will($this->returnCallback(function ($storage) { /** @var AclAnnotationStorage $storage */ $storage->add(new AclAnnotation(['id' => 'test', 'type' => 'entity']), 'SomeClass', 'SomeMethod'); })); $this->assertEquals('test', $this->provider->findAnnotationById('test')->getId()); $this->assertNull($this->provider->findAnnotationById('unknown')); $this->assertEquals('test', $this->provider->findAnnotation('SomeClass', 'SomeMethod')->getId()); $this->assertNull($this->provider->findAnnotation('SomeClass', 'UnknownMethod')); $this->assertNull($this->provider->findAnnotation('UnknownClass', 'SomeMethod')); $this->assertCount(1, $this->provider->getAnnotations()); $this->assertCount(1, $this->provider->getAnnotations('entity')); $this->assertCount(0, $this->provider->getAnnotations('action')); }
/** * Gets ACL annotation is bound to the given class/method * * @param string $class * @param string $method * @return Acl|null */ public function getClassMethodAnnotation($class, $method) { return $this->annotationProvider->findAnnotation($class, $method); }