I want to use this in my controllers:
#[VerifyPermissions('writeDocs')]
public function testAction()
{
return new JsonResponse(["status" => "OK"]);
}
This is my VerifyPermissions class:
#[Attribute]
class VerifyPermissions
{
public function __construct(
private EntityManagerInterface $em,
private TokenStorageInterface $tokenStorage,
private string $permissionsToCheck
) {
$this->em = $em;
$this->tokenStorage = $tokenStorage;
...
}
}
But I got this error:
Argument #1 ($em) must be of type DoctrineORMEntityManagerInterface, string given
I though adding some autowire config in the services.yaml like:
AppSecurityVerifyPermissions:
arguments:
$em: "@doctrine.orm.entity_manager"
$tokenStorage: "@security.token_storage"
But this does not work.