0

I've this route defined in a controller:

/**
 * @Secure(roles="IS_AUTHENTICATED_FULLY")
 * @Route(
 *        "/proccess/{slug}", 
 *        requirements={"slug": "^([a-zA-Z0-9]*-[a-zA-Z0-9]*)+$"}, 
 *        name="registerRPNI"
 * )
 */
public function indexAction(Request $request)
{
    ......
}

And I need to set the right route in KNPMenuBundle MenuBuilder class. I'm doing as follow:

->addChild('Process RPNI', array(
     'uri' => '/process/national-and-imported-products-registration',
))

And it works for dev environment since route shows the right page and execute the right code but if I move away from dev and goes live to prod then I got a 404 Not found, what I'm doing wrong in this case? What should be the right way to generate the routes inside the MenuBuilder class? Any advice around this?

ReynierPM
  • 17,594
  • 53
  • 193
  • 363
  • 1
    Why not just use `'route' => 'registerRPNI', 'routeParameters' => array('slug' => 'national-and-imported-products-registration')` as you would usually? – qooplmao Nov 18 '14 at 20:40
  • @Qoop I did not know that way until now, I figure out how to get it done by injecting "`@route`" to the service where KnpMenu is defined and then setting this `$this->router->generate('registerRPNI', array('slug' => 'registerRPNI'))` to the `uri` param. I think is the same approach in different flavors, right? – ReynierPM Nov 18 '14 at 20:42
  • You don't even need to do that. The menu factory already has the route generator so you can add a route and routeParameters in a childs attributes and it will generate the uri for you. Check out https://github.com/KnpLabs/KnpMenuBundle/blob/master/Resources/doc/index.md#method-a-the-easy-way-yay – qooplmao Nov 18 '14 at 20:58

0 Answers0