I have a route
detail: path: /{code} defaults: { _controller: controller.main:detailAction } I also have a controller for this route
public function detailAction(Request $request, string $code, int $size, array $params): Response { } My question is: how can I say to controller which parameters he should take as int $size and array $params ? I have found in symfony docs that I may specifically mention params in defaults section with default values like this
detail: path: /{code} defaults: { _controller: controller.main:detailAction } size: 1 params: "Hello world!" But that is not what I want since I shouldn't have a default value for this params but it ought to be taken directly from request. How do I do this without making my route like /{code}/{size} ? And even in this case what do I do with an array?
detailAction()statement requires all arguments, it always must be all parameters passed. But only$codeis part of the path, others I just want to have passeddetailAction(..., int $size = null, array $params = null). Then you can test if they're set, but I don't believe (?) Symfony's router will see those as required arguments.