Closed julienfollow closed 3 years ago
A route needs to reference a callable that can be executed by the Symfony HTTP kernel. A class is no callable in PHP. If you have an __invoke()
method, you need to put the annotation on that method.
Thank's you @xabbuh, i do like that, the night is good to reflexion ;)
<?php
declare(strict_types=1);
namespace Om\Actions\User;
use FOS\RestBundle\Controller\Annotations as Rest;
use Om\Actions\Get;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class GetUser
* @package Om\Actions\User
*/
class GetUser extends Get
{
/**
* @Rest\Get(
* path="/users/{uuid}",
* name = "get_user",
* requirements = {"id"="\d+"}
* )
*/
public function __invoke(Request $request)
{
return parent::__invoke($request);
}
}
Hello Do we have a possibility to use their annotations on the class ? I use method __invoke. My pattern is ADR. One class is one action. For example =>
But i have this error ... I understand error. After read doc, I found nothing about this possibility.