I want to create navigation from my database, where I store the names of my routes as destination links. My controller simply retrieves all the necessary navigation entries from the database and returns the rows that are used directly in my branch template.
public function myAction() { $em = $this->getDoctrine()->getManager(); $navi = $em->getRepository('myBundle:Navigation')->findAll(); return array("navi" => $navi); }
Thus, it is likely that the route does not exist, resulting in a 500 error.
I need a way to check if a named route exists or not. I tried to test it with {% if path('routeName') is defined %} ... {% endif %} , but this will not work.
AFAIK my controller can catch Twig exceptions, but I just want the branch to ignore the navigation entries that are invalid. Any idea?
exception path symfony twig routes
user2476294
source share