/** * Retourne un message pour un template en base * @param string $template_name nom du template * @param string $locale langue * @param array $template_vars tableau de variable * @return SwiftMessage */ public function getMessageForTemplate($template_name, $locale = 'en', $template_vars = array()) { $template = $this->dm->getRepository($this->template_class)->find($template_name); if (is_null($template)) { throw new \Exception(sprintf('Template "%s" not found', $template_name)); } // Refresh template based on locale $template->setTranslatableLocale($locale); $this->dm->refresh($template); // Assign template engine $template->setTwigEngine($this->twig); // Construct and return message return \Swift_Message::newInstance()->setSubject($template->getFinalSubject($template_vars))->setBody($template->getFinalBody($template_vars), 'text/html'); }
/** * @var Doctrine\Common\Persistence\ObjectManager @om * @var Newscoop\News\ItemService $itemService */ public function __construct(\Doctrine\Common\Persistence\ObjectManager $om, ItemService $itemService) { $this->om = $om; $this->repository = $this->om->getRepository('Newscoop\\News\\ReutersFeed'); $this->itemService = $itemService; }