0

使用 Symfony(我从 Symfony 4 学习),我希望根据连接用户的角色允许访问自定义控制器。

在注释中,我看到我可以通过以下方式管理角色访问:

/**
 * @Security("has_role('ROLE_ADMIN')")
 */
public function hello($name)
{
...

是否可以像这样在注释中调用函数?

/**
 * @Security("my_verification_function")
 */
public function hello($name)
{
...
}
...
private function verification_function(){
   //some process
   if (...) 
     return true; // the user can access to the page
   else ... 
     return false; // the user can't access to the page
}
4

1 回答 1

0

是使用 Symfony 和 Doctrine Common 来创建强大注释的一个很好的例子。

于 2018-01-05T16:33:37.653 回答