php - Symfony custom routing -
i'm using routing annotations in symfony2 project , need implement new feature. need generate page depends on current city. city passed in actions this:
/** * @route("/") * @route("/{name}" */
and need custom requirements city parameter. want match route if passed city contained in dynamic array loaded database, in other case shoud go next route, without throwing exception.
i tried use requirements, not figured out how pass object that. expressions same problem, need pass service don't know how.
you can try using annotation param converter.
use sensio\bundle\frameworkextrabundle\configuration\route; use sensio\bundle\frameworkextrabundle\configuration\paramconverter;
/** * @route("/city/{name}") * @paramconverter("city", class="appbundle:city", options={"entity_manager" = "foo"}) */ public function showaction(city $city) { }
else, guess can in controller.
but please, note using 2 routs same controller action isn't real practise.
and stated in comment, should able deal kind of verification inside controller, redirect it's needed
Comments
Post a Comment