使用 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
}