出现此问题一次,因为我想将数据库中的内容放在前端。我显然是在一个名为AppTriggerBuildCommand的类中生成命令,但是如图所示,一旦代码达到此值就会出现问题:
{{ render(controller('AppBundle:Menu:footerLarge', { 'language': language } )) }}
在page.html.twig中。
[Twig_Error_Runtime]
An exception has been thrown during the rendering of a template ("Rendering a fragment can only be done when handling a Request.").
Exception trace:
() at /var/www/html/iclei/src/AppBundle/Resources/views/page.html.twig:23
Twig_Template->displayWithErrorHandling() at /var/www/html/iclei/vendor/twig/twig/lib/Twig/Template.php:366
Twig_Template->display() at /var/www/html/iclei/vendor/twig/twig/lib/Twig/Template.php:374
Twig_Template->render() at /var/www/html/iclei/vendor/twig/twig/lib/Twig/Environment.php:289
Twig_Environment->render() at /var/www/html/iclei/src/AppBundle/Command/AppTriggerBuildCommand.php:69
AppBundle\Command\AppTriggerBuildCommand->pageAction() at /var/www/html/iclei/src/AppBundle/Command/AppTriggerBuildCommand.php:38
AppBundle\Command\AppTriggerBuildCommand->execute() at /var/www/html/iclei/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:242
Symfony\Component\Console\Command\Command->run() at /var/www/html/iclei/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:861
Symfony\Component\Console\Application->doRunCommand() at /var/www/html/iclei/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:193
Symfony\Component\Console\Application->doRun() at /var/www/html/iclei/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:83
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/iclei/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:117
Symfony\Component\Console\Application->run() at /var/www/html/iclei/app/console:27
我已经尝试了另一种建议的两种解决方案。一旦我尝试重建bootstrap.php,它就不会改变一件事。 这是在
中/var/www/html/iclei/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
另一方面我们可以在这里找到它:
/var/www/html/iclei/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php
有人可以帮我解决这个问题吗?
答案 0 :(得分:1)
您应该在命令中创建一个请求并将其添加到请求堆栈
$r = new Request();
$r->setLocale('en');
$container->set('request', $r, 'request');
$container->get('request_stack')->push($r);