में कमांड लाइन से ईमेल भेजें मुझे symfony2 में कमांड क्लास से एक ट्विग टेम्पलेट प्रस्तुत करने की आवश्यकता है।symfony2
namespace IT\bBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class CronCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('send:emails')
->setDescription('Envio programado de emails');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$message = \Swift_Message::newInstance()
->setSubject('bla bla')
->setFrom('[email protected]')
->setTo('[email protected]')
->setCharset('UTF-8')
->setContentType('text/html')
->setBody($this->renderView('mainBundle:Email:default.html.twig'));
$this->getContainer()->get('mailer')->send($message);
$output->writeln('Enviado!');
}
}
लेकिन जब मैं आदेश php app/console send:emails
मैं निम्नलिखित त्रुटि मिलती है निष्पादित करें:
Fatal error: Call to undefined method
IT\bBundle\Command\CronCommand::renderView()
मैं कैसे दृश्य प्रस्तुत कर सकते हैं?
बस एक पैर नोट: यदि आप थोक ईमेल भेजने की योजना बना रहे हैं तो यह ऐसा करने का तरीका नहीं है। अगर यह थोड़ी देर में ठीक है तो यह ठीक रहेगा। – transilvlad