Sonata hybrid page: Unable to find template ""

时间:2015-05-04 19:30:30

标签: symfony symfony-sonata sonata

When I create a hybrid or dynamic page in SonataTestBundle, it always throws "Unable to find template ""." exception.

When I create a hybrid page in SonataDemoBundle it works just fine.

For some reason an empty template name is being passed.

What am I missing?

Any help is appreciated.

I followed these steps

  • Just create a route
  • create the related controller
  • create the related template (with no main html header, only the body)
  • run the task sonata:page:update-core-route --site=all

My Controller:

namespace Sonata\Bundle\TestBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class DefaultController extends Controller {

  public function testAction (Request $request) {

     return $this->render('SonataTestBundle:Default:test.html.twig');
  }
}

My View

{# Sonata\Bundle\TestBundle\Resources\views\Default #]
{% extends '::empty.html.twig' %}

{% block page %}
  <h2>Test</h2>
{% endblock %}

My Route

<route id="sonata_default_test" pattern="/test">
    <default key="_controller">SonataTestBundle:Default:test</default>
</route>

Then I run the following tasks

app/console sonata:page:update-core-route --site=all
app/console sonata:page:create-snapshots --site=all

Stack

[1] InvalidArgumentException: Unable to find template "".
at n/a
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 128

at Symfony\Bridge\Twig\TwigEngine->load(null)
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 50

at Symfony\Bridge\Twig\TwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 67

at Symfony\Bundle\TwigBundle\TwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Debug/TimedTwigEngine.php line 50

at Symfony\Bundle\TwigBundle\Debug\TimedTwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 370

at FOS\RestBundle\View\ViewHandler->renderTemplate(object(View), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 439

at FOS\RestBundle\View\ViewHandler->initResponse(object(View), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 418

at FOS\RestBundle\View\ViewHandler->createResponse(object(View), object(SiteRequest), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 311

at FOS\RestBundle\View\ViewHandler->handle(object(View), object(SiteRequest))
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/ViewResponseListener.php line 136

at FOS\RestBundle\EventListener\ViewResponseListener->onKernelView(object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
    in  line 

at call_user_func(array(object(ViewResponseListener), 'onKernelView'), object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php line 61

at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseForControllerResultEvent), 'kernel.view', object(ContainerAwareEventDispatcher))
    in  line 

at call_user_func(object(WrappedListener), object(GetResponseForControllerResultEvent), 'kernel.view', object(ContainerAwareEventDispatcher))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 164

at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener)), 'kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 53

at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php line 167

at Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php line 112

at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/app/bootstrap.php.cache line 3032

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(SiteRequest), '1')
    in /var/www/topf-helden/app/bootstrap.php.cache line 2991

at Symfony\Component\HttpKernel\HttpKernel->handle(object(SiteRequest), '1', true)
    in /var/www/topf-helden/app/bootstrap.php.cache line 3140

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(SiteRequest), '1', true)
    in /var/www/topf-helden/app/bootstrap.php.cache line 2384

at Symfony\Component\HttpKernel\Kernel->handle(object(SiteRequest))
    in /var/www/topf-helden/web/app_dev.php line 30

[2] Twig_Error_Loader: Unable to find template "".
at n/a
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php line 91

at Symfony\Bundle\TwigBundle\Loader\FilesystemLoader->findTemplate('')
    in /var/www/topf-helden/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line 138

at Twig_Loader_Filesystem->getCacheKey('')
    in /var/www/topf-helden/vendor/twig/twig/lib/Twig/Environment.php line 266

at Twig_Environment->getTemplateClass('', null)
    in /var/www/topf-helden/vendor/twig/twig/lib/Twig/Environment.php line 324

at Twig_Environment->loadTemplate('')
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 126

at Symfony\Bridge\Twig\TwigEngine->load(null)
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 50

at Symfony\Bridge\Twig\TwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 67

at Symfony\Bundle\TwigBundle\TwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Debug/TimedTwigEngine.php line 50

at Symfony\Bundle\TwigBundle\Debug\TimedTwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 370

at FOS\RestBundle\View\ViewHandler->renderTemplate(object(View), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 439

at FOS\RestBundle\View\ViewHandler->initResponse(object(View), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 418

at FOS\RestBundle\View\ViewHandler->createResponse(object(View), object(SiteRequest), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 311

at FOS\RestBundle\View\ViewHandler->handle(object(View), object(SiteRequest))
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/ViewResponseListener.php line 136

at FOS\RestBundle\EventListener\ViewResponseListener->onKernelView(object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
    in  line 

at call_user_func(array(object(ViewResponseListener), 'onKernelView'), object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php line 61

at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseForControllerResultEvent), 'kernel.view', object(ContainerAwareEventDispatcher))
    in  line 

at call_user_func(object(WrappedListener), object(GetResponseForControllerResultEvent), 'kernel.view', object(ContainerAwareEventDispatcher))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 164

at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener)), 'kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 53

at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php line 167

at Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php line 112

at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/app/bootstrap.php.cache line 3032

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(SiteRequest), '1')
    in /var/www/topf-helden/app/bootstrap.php.cache line 2991

at Symfony\Component\HttpKernel\HttpKernel->handle(object(SiteRequest), '1', true)
    in /var/www/topf-helden/app/bootstrap.php.cache line 3140

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(SiteRequest), '1', true)
    in /var/www/topf-helden/app/bootstrap.php.cache line 2384

at Symfony\Component\HttpKernel\Kernel->handle(object(SiteRequest))
    in /var/www/topf-helden/web/app_dev.php line 30

[3] InvalidArgumentException: Unable to find template "" : "An empty file name is not valid to be located.".
at n/a
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php line 81

at Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator->locate(object(TemplateReference))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php line 84

at Symfony\Bundle\TwigBundle\Loader\FilesystemLoader->findTemplate('')
    in /var/www/topf-helden/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line 138

at Twig_Loader_Filesystem->getCacheKey('')
    in /var/www/topf-helden/vendor/twig/twig/lib/Twig/Environment.php line 266

at Twig_Environment->getTemplateClass('', null)
    in /var/www/topf-helden/vendor/twig/twig/lib/Twig/Environment.php line 324

at Twig_Environment->loadTemplate('')
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 126

at Symfony\Bridge\Twig\TwigEngine->load(null)
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 50

at Symfony\Bridge\Twig\TwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 67

at Symfony\Bundle\TwigBundle\TwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Debug/TimedTwigEngine.php line 50

at Symfony\Bundle\TwigBundle\Debug\TimedTwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 370

at FOS\RestBundle\View\ViewHandler->renderTemplate(object(View), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 439

at FOS\RestBundle\View\ViewHandler->initResponse(object(View), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 418

at FOS\RestBundle\View\ViewHandler->createResponse(object(View), object(SiteRequest), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 311

at FOS\RestBundle\View\ViewHandler->handle(object(View), object(SiteRequest))
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/ViewResponseListener.php line 136

at FOS\RestBundle\EventListener\ViewResponseListener->onKernelView(object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
    in  line 

at call_user_func(array(object(ViewResponseListener), 'onKernelView'), object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php line 61

at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseForControllerResultEvent), 'kernel.view', object(ContainerAwareEventDispatcher))
    in  line 

at call_user_func(object(WrappedListener), object(GetResponseForControllerResultEvent), 'kernel.view', object(ContainerAwareEventDispatcher))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 164

at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener)), 'kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 53

at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php line 167

at Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php line 112

at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/app/bootstrap.php.cache line 3032

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(SiteRequest), '1')
    in /var/www/topf-helden/app/bootstrap.php.cache line 2991

at Symfony\Component\HttpKernel\HttpKernel->handle(object(SiteRequest), '1', true)
    in /var/www/topf-helden/app/bootstrap.php.cache line 3140

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(SiteRequest), '1', true)
    in /var/www/topf-helden/app/bootstrap.php.cache line 2384

at Symfony\Component\HttpKernel\Kernel->handle(object(SiteRequest))
    in /var/www/topf-helden/web/app_dev.php line 30

[4] InvalidArgumentException: An empty file name is not valid to be located.
at n/a
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/Config/FileLocator.php line 39

at Symfony\Component\Config\FileLocator->locate('', null, true)
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Config/FileLocator.php line 54

at Symfony\Component\HttpKernel\Config\FileLocator->locate('', null)
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php line 79

at Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator->locate(object(TemplateReference))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php line 84

at Symfony\Bundle\TwigBundle\Loader\FilesystemLoader->findTemplate('')
    in /var/www/topf-helden/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line 138

at Twig_Loader_Filesystem->getCacheKey('')
    in /var/www/topf-helden/vendor/twig/twig/lib/Twig/Environment.php line 266

at Twig_Environment->getTemplateClass('', null)
    in /var/www/topf-helden/vendor/twig/twig/lib/Twig/Environment.php line 324

at Twig_Environment->loadTemplate('')
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 126

at Symfony\Bridge\Twig\TwigEngine->load(null)
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 50

at Symfony\Bridge\Twig\TwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 67

at Symfony\Bundle\TwigBundle\TwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Debug/TimedTwigEngine.php line 50

at Symfony\Bundle\TwigBundle\Debug\TimedTwigEngine->render(null, array('data' => null))
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 370

at FOS\RestBundle\View\ViewHandler->renderTemplate(object(View), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 439

at FOS\RestBundle\View\ViewHandler->initResponse(object(View), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 418

at FOS\RestBundle\View\ViewHandler->createResponse(object(View), object(SiteRequest), 'html')
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/View/ViewHandler.php line 311

at FOS\RestBundle\View\ViewHandler->handle(object(View), object(SiteRequest))
    in /var/www/topf-helden/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/ViewResponseListener.php line 136

at FOS\RestBundle\EventListener\ViewResponseListener->onKernelView(object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
    in  line 

at call_user_func(array(object(ViewResponseListener), 'onKernelView'), object(GetResponseForControllerResultEvent), 'kernel.view', object(TraceableEventDispatcher))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php line 61

at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseForControllerResultEvent), 'kernel.view', object(ContainerAwareEventDispatcher))
    in  line 

at call_user_func(object(WrappedListener), object(GetResponseForControllerResultEvent), 'kernel.view', object(ContainerAwareEventDispatcher))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 164

at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener)), 'kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 53

at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php line 167

at Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php line 112

at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.view', object(GetResponseForControllerResultEvent))
    in /var/www/topf-helden/app/bootstrap.php.cache line 3032

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(SiteRequest), '1')
    in /var/www/topf-helden/app/bootstrap.php.cache line 2991

at Symfony\Component\HttpKernel\HttpKernel->handle(object(SiteRequest), '1', true)
    in /var/www/topf-helden/app/bootstrap.php.cache line 3140

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(SiteRequest), '1', true)
    in /var/www/topf-helden/app/bootstrap.php.cache line 2384

at Symfony\Component\HttpKernel\Kernel->handle(object(SiteRequest))
    in /var/www/topf-helden/web/app_dev.php line 30

0 个答案:

没有答案