RequestAttributeValueResolver
отрабатывает раньше, соответственно до вашего резолвера дело не доходит.App\ArgumentResolver\UserIdResolver:
class: App\ArgumentResolver\UserIdResolver
tags:
- { name: controller.argument_value_resolver, priority: 101 }
class UserController {
/**
* @Rest\Get("/users/{userId}")
*/
public function getUserById(UserId $id): void {
var_dump($id);
die('1234');
}
}
App\ArgumentResolver\UserIdResolver:
class: App\ArgumentResolver\UserIdResolver
tags:
- { name: controller.argument_value_resolver, priority: 50 }
controller.argument_value_resolver
добавляется автоматически на основании интерфейса page_item:
path: /{parameters}
defaults: { _controller: AppBundle\Controller\Page\PageController:itemAction }
requirements:
parameters: ".+"
public function itemAction(Request $request, $parameters)
{
$parts = explode('/', $parameters);
// ...
}
The feature explained in this article doesn't work in modern Symfony applications that have no bundles. The workaround is to temporarily create a bundle. See doctrine/doctrine#729 for details.
php bin/console doctrine:mapping:convert --from-database annotation ./src/Entity
php bin/console cache:clear --no-warmup --env=prod
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpKernel\Kernel;
class HttpCacheClearCommand extends Command
{
/**
* @var string
*/
private $cacheDir;
public function __construct($name, $cacheDir)
{
parent::__construct($name);
$this->cacheDir = $cacheDir;
}
protected function configure()
{
$this
->setDescription('Clear http-cache')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$exec = sprintf('rm -rf %s/*', $this->cacheDir);
exec($exec);
}
}
cache_dir: '%kernel.cache_dir%/http_cache'
bin/console cache:pool:clear