using symfony 3.0 where I want to get the ID from the URL.
/**
* @Route("/pathtocontent/{id}-{name}", defaults={"id"=null,"name"=null},
requirements={"name"="[a-zA-Z0-9\-_\/]+", "id"="\d+"}, name="routingname")
* @Route("/pathtocontent/{name}-{id}", defaults={"id"=null,"name"=null},
requirements={"name"="[a-zA-Z0-9\-_\/]+", "id"="\d+"},
name="routingname_alias")
*/
public function pathAction(Request $request, $id = null) {
}
So I have 2 rules for the same action. The URL can be:
/pathtocontent/Name-part-comes-here-1234
and also could be like that:
/pathtocontent/1234-Name-part-comes-here
The problem is the first case, where the name get all the: Name-part-comes-here-1234 value and the Id is null
How can I force the first case to parse the Id value out too, so I need to get the Id (1234) from the :
/pathtocontent/Name-part-comes-here-1234