0

我的问题是我的控制器成功完成,但是 twig/view 然后呈现空白。请求不返回 html。

我的控制器以以下方式结束:

    $logger->info('Now sending song [' . $song->getId() . ' to twig');
    return array('song'=>$song);
}

由于我没有错误,因此很难找到问题所在。我所拥有的只是来自独白的 dev.log:

[2011-10-04 07:41:03] app.INFO: Now sending song [672] to twig [] []
[2011-10-04 07:41:03] event.DEBUG: Notified event "kernel.view" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelView". [] []
[2011-10-04 07:41:03] event.DEBUG: Listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelView" stopped propagation of the event "kernel.view". [] []
[2011-10-04 07:41:03] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse". [] []
[2011-10-04 07:41:03] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\SecurityBundle\EventListener\ResponseListener::onKernelResponse". [] []
[2011-10-04 07:41:03] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\FirePHPHandler::onKernelResponse". [] []
[2011-10-04 07:41:03] event.DEBUG: Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\CacheListener::onKernelResponse". [] []
[2011-10-04 07:41:03] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse". [] []
[2011-10-04 07:41:03] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse". [] []

我认为第 3 行一定是问题所在,但我不知道这意味着什么,或者任何解决方法。

编辑:如果我更改我的控制器: - 删除 @Template() - 结束看起来像:

$logger->info('Now sending song [' . $song->getId() . '] to twig');
$content = $this->renderView('MyPadBundle:Play:index.html.twig', array('song'=>$song));
$logger->info('content rendered');
return new Response($content);

然后我的 dev.log 是:

[2011-10-04 09:42:52] app.INFO: Now sending song [189] to twig [] []
[2011-10-04 09:42:53] app.INFO: content rendered [] []
[2011-10-04 09:42:53] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse". [] []
[2011-10-04 09:42:53] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\SecurityBundle\EventListener\ResponseListener::onKernelResponse". [] []
[2011-10-04 09:42:53] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\FirePHPHandler::onKernelResponse". [] []
[2011-10-04 09:42:53] event.DEBUG: Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\CacheListener::onKernelResponse". [] []
[2011-10-04 09:42:53] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse". [] []
[2011-10-04 09:42:53] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse". [] []

就像内核无法返回响应一样?

4

1 回答 1

1

我不知道出了什么问题,但这确实解决了它:

$logger->info('Now sending song [' . $song->getId() . '] to twig');
$em->clear();
return array('song'=>$song);

应该知道这将是缺乏错误报告的教义。无论如何,该表只有 1000 行,所以不确定对于树枝来说太多处理太多了,特别是因为我只通过了一行/实体。

Have to admit I'm disappointed with doctrine; or maybe the problem lies with bad design on symfony's templating?

于 2011-10-04T12:32:53.453 回答