Richard Ybias
Richard Ybias

Reputation: 335

Symfony Load Twig Template For Email

I got error in symfony twig template during load.

Do I need to include this : use 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).

This is the folder structure.

src/Btn/CrudBundle/command/SystemCommand.php : Class location

src/Btn/CrudBundle/Resources/views/email.html.twig : Template location

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('[email protected]')
            ->setTo('[email protected]')
            ->setBody(
                $this->getContainer()->get('templating')->render(
                    'CrudBundle:email.html.twig',
                    array('name' => $staffer->getUser())
                )
            )
        ;
        $this->get('mailer')->send($message);          
    }
}

Please help

Upvotes: 2

Views: 5112

Answers (1)

sean662
sean662

Reputation: 706

Try CrudBundle::email.html.twig instead of CrudBundle:email.html.twig.

Upvotes: 2

Related Questions