[英]Render twig templates in Symfony 2.1
I am migrating my app to Symfony 2.1 but I'm facing a big error. 我正在将应用程序迁移到Symfony 2.1,但遇到一个大错误。 I've got a command which calls the templating service to render a twig template.
我有一个命令,该命令调用模板服务以渲染树枝模板。 The code +- is:
代码+-是:
$content = $this->getContainer()->get('templating')->render('XBundle:Pdf:x.pdf.twig', array(
'variablea' => '',
'variableb' => ''
));
It was working without any problem in Symfony 2.0.X. 在Symfony 2.0.X中它可以正常工作。 But after migrating into Symfony 2.1, when that piece of code is called, an exception occurs:
但是在移植到Symfony 2.1之后,调用该段代码时,会发生异常:
Fatal error: Call to undefined method Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\TemplateLocator::isFresh() in /vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php on line 49
致命错误:调用第49行上/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php中未定义的方法Symfony \\ Bundle \\ FrameworkBundle \\ Templating \\ Loader \\ TemplateLocator :: isFresh()
I've reported that in symfony/asseticbundle tracker on github like 14 days ago and nobody answers, which makes me think that I am the problem here... ( https://github.com/symfony/AsseticBundle/issues/122 ) 我已经报告说在github上的symfony / asseticbundle跟踪器中,就像14天前一样,没有人回答,这让我认为我是这里的问题...( https://github.com/symfony/AsseticBundle/issues/122 )
What am I doing wrong? 我究竟做错了什么?
Thanks!! 谢谢!!
您是否清除了缓存( php app/console cache:clear
)并重建了引导文件?
Here are a few suggestions: 这里有一些建议:
Check if you are using proper versions of the Symfony bundles. 检查您使用的Symfony捆绑软件是否正确。 Compare the bundles versions in your composer.json file with versions in the default Symfony 2.1 distribution: https://github.com/symfony/symfony-standard/blob/v2.1.2/composer.json
将composer.json文件中的捆绑软件版本与默认Symfony 2.1发行版中的版本进行比较: https : //github.com/symfony/symfony-standard/blob/v2.1.2/composer.json
Make sure your Symfony 2.1 installation is not still using Symfony 2.0 cache files. 确保您的Symfony 2.1安装仍未使用Symfony 2.0缓存文件。 If you are not sure about this delete the cache folder content.
如果不确定,请删除缓存文件夹的内容。 In your project root directory do
rm -rf app/cache/*
and set up appropiate permissions as explained in the documentation: http://symfony.com/doc/current/book/installation.html#configuration-and-setup 在项目根目录中,执行
rm -rf app/cache/*
并按照文档中的说明设置适当的权限: http : //symfony.com/doc/current/book/installation.html#configuration-and-setup
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.