Answer the question
In order to leave comments, you need to log in
How to configure routing in symfony 3 so that page nesting level is unlimited?
Good afternoon!
Is it possible to assign processing of urls with unlimited nesting to one action in symfony?
Or will you still have to limit the nesting and do an action for each level (an example of an action for page 4 of the nesting level below)?
/**
* @Route("/{part1}/{part2}/{part3}/{part4}", name="simple_page")
* @param Request $request
* @param $part1
* @param $part2
* @param $part3
* @param $part4
* @return Response
*/
public function pageAction(Request $request, $part1, $part2, $part3, $part4)
{
return $this->render('default/index.html.twig', [
"path1" => $part1,
"path2" => $part2,
"path3" => $part3,
"path4" => $part4
]);
}
Answer the question
In order to leave comments, you need to log in
page_item:
path: /{parameters}
defaults: { _controller: AppBundle\Controller\Page\PageController:itemAction }
requirements:
parameters: ".+"
public function itemAction(Request $request, $parameters)
{
$parts = explode('/', $parameters);
// ...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question