I have a route that creates several database entries. After the creation I'd like to forward to a route that fetches those entries and displays them.
This is the route for fetching/displaying:
/**
* @Route("/admin/app", name="appTourOverview")
*/
public function appTourOverviewAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
/* Get Network for User */
$network = $this->getUser()->getNetwork();
$tours = $em->getRepository('AppBundle:Tour')->toursTodayByNetwork($network);
return $this->render(':app:index.html.twig', array(
'tour' => $tours,
'imagePath' => Constants::IMAGE_PATH_DEV,
'imagePathGreen' => Constants::IMAGE_PATH_DEV_GREEN,
'imagePathYear' => Constants::IMAGE_PATH_DEV_YEAR,
));
}
and this is how I redirected from the "database route":
return $this->redirectToRoute('appTourOverview', array(), 301);
but this gets cached and the database entries are never created...
I tried:
I copied everything from the "display route" and let it return the database stuff immediately.
/* Get Network for User */
$network = $this->getUser()->getNetwork()->getId();
$tours = $em->getRepository('AppBundle:Tour')->toursTodayByNetwork($network);
return $this->render(':checker:index.html.twig', array(
'tour' => $tours,
'imagePath' => Constants::IMAGE_PATH_DEV,
'imagePathGreen' => Constants::IMAGE_PATH_DEV_GREEN,
'imagePathYear' => Constants::IMAGE_PATH_DEV_YEAR,
));
instead of the redirect. Unfortunately this only works after a refresh? ($tours
is empty the first time)
Any ideas?