Hi,
I've some problems using the ReflectionAnnotatedMethod class.
- I created the class Permission, extending Annotation
- I created the class ModuleNews with the method listAction and the Annotation @Permission('ADD')
- I tried to get the Permission class, but it does not work
Does anyone have some ideas?
<?php
class ModuleNews extends CoreModule {
/**
*
* @param type $newst_id
* @param type $page
* @param type $pageSize
* @Permission('ADD')
*/
protected function listAction($newst_id = 1, $page = null, $pageSize = null) {
}
}
class Permission extends Annotation {
private $perm;
public function __construct($options) {
parent::__construct();
if (!isset($options['value'])) {
throw new Exception("Permission is not set");
}
$this->perm = $options['value'];
}
public function getPermission() {
return $this->perm;
}
}
$reflectionMethod = new ReflectionAnnotatedMethod('ModuleNews', 'listAction');
if ($reflectionMethod->hasAnnotation('Permission')) {
$permission = $reflectionMethod->getAnnotation('Permission')->getPermission();
echo $permission;
}
?>