0

With Symfony (I learn from Symfony 4), I want allow access to a custom controller depending of the role of the connected user.

In the annotations , I see I can manage the role access with :

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

Is it possible to call a function in the annotation like this ?

/**
 * @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
}
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
spacecodeur
  • 2,206
  • 7
  • 35
  • 71

1 Answers1

0

Here is a good example of using Symfony with Doctrine Common in order to create powerful annotations.

Imanali Mamadiev
  • 2,604
  • 2
  • 15
  • 23