我在加载期间在symfony twig模板中出错。
我是否需要包含此内容:使用Sensio \ Bundle \ FrameworkExtraBundle \ Configuration \ Template;
[InvalidArgumentException]
Unable to find template "CrudBundle:email.html.twig".
[Twig_Error_Loader]
Unable to find template "CrudBundle:email.html.twig".
[Twig_Error_Loader]
Unable to find template "CrudBundle:email.html.twig" (looked into: C:\xampp
\htdocs\sample\vendor\symfony\symfony\src\Symfony\Bridge\Twig/Resourc
es/views/Form).
这是文件夹结构。
src/Btn/CrudBundle/command/SystemCommand.php
:班级位置
src/Btn/CrudBundle/Resources/views/email.html.twig
:模板位置
class SystemCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('cron:email:send')
->setDescription('Verifies that accounts');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln("This is a test");
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('sample@sample.com')
->setTo('sample@sample.com')
->setBody(
$this->getContainer()->get('templating')->render(
'CrudBundle:email.html.twig',
array('name' => $staffer->getUser())
)
)
;
$this->get('mailer')->send($message);
}
}
请帮忙
答案 0 :(得分:2)
尝试使用CrudBundle::email.html.twig
代替CrudBundle:email.html.twig
。