我在Symfony的初學者,所以我跟着一個教程回合的Symfony 3.當我嘗試刷新()我得到一個錯誤的Symfony:錯誤時的flush()
"This page isn't working
localhost didn't send any data
ERR_EMPTY_RESPONSE"
當我註釋此行中,頁面工作...這裏是代碼:
public function editAction($id, Request $request) {
$em = $this->getDoctrine()->getManager();
$advert = $em->getRepository('OCPlatformBundle:Advert')->find($id);
if (null === $advert) {
throw new NotFoundHttpException("L'annonce d'id ".$id." n'existe pas.");
}
$listCategories = $em->getRepository('OCPlatformBundle:Category')->findAll();
foreach ($listCategories as $category) {
$advert->addCategory($category);
}
$em->flush();
if ($request->isMethod('POST')) {
$request->getSession()->getFlashBag()->add('notice', 'Annonce bien modifiée.');
return $this->redirectToRoute('oc_platform_view', array('id' => 5));
}
return $this->render('OCPlatformBundle:Advert:edit.html.twig', array(
'advert' => $advert
));
}
任何想法? 謝謝你的幫助!