1
我學習的Symfony 2,我有問題:Symfony 2基本控制器 - 返回響應?
我的代碼是:
public function showListAction()
{
$ar = $this->getDoctrine()
->getRepository('AcmeHelloBundle:ModGlobalAspectRatio')
->findAll();
return $this->render('AcmeHelloBundle:Test:showList.html.php', array('recs' => $ar));
}
public function updateAction($id, $name)
{
$em = $this->getDoctrine()->getManager();
$ar = $em->getRepository('AcmeHelloBundle:ModGlobalAspectRatio')->find($id);
$ar->setName($name);
$em->flush();
$content = $this->forward('AcmeHelloBundle:Hello:showList');
return new Response($content);
}
我在 「更新」 我的第一個動作 「showList」 運行。
沒有return new Response()
我有錯誤:
爲什麼要使用return new Response
後我有:
The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller?
爲什麼..其litttle愚蠢..
我的主要問題是,我不明白這一點文本在頁頂:
HTTP/1.0 200 OK Cache-Control: no-cache Date: Fri, 28 Feb 2014 19:42:48 GMT X-Debug-Token: f0ada0 X-Debug-Token-Link: /symfony2/web/app_dev.php/_profiler/f0ada0
我不要編輯這個奇怪的字符串..我如何刪除它?
謝謝! :)
爲什麼不使用'return $ this-> forward('AcmeHelloBundle:Hello:showList');'而不是使用完全無用的'$ content'變量? –