/** * {@inheritdoc} */ public function load($name, $type = MailTypes::TYPE_ALL) { if (isset($this->mails[$name]) && MailUtil::isValid($this->mails[$name], $type)) { return $this->mails[$name]; } throw new UnknownMailException($name, $type); }
/** * {@inheritdoc} */ public function load($name, $type = MailTypes::TYPE_ALL) { $repo = $this->om->getRepository($this->class); $mail = $repo->findOneBy(array('name' => $name, 'enabled' => true, 'type' => MailUtil::getValidTypes($type))); if (null !== $mail) { return $mail; } throw new UnknownMailException($name, MailTypes::TYPE_ALL); }
/** * @dataProvider getTypes * * @param string $type The entry type * @param string[] $validTypes The valid types for entry */ public function testGetValidTypes($type, $validTypes) { $this->assertEquals($validTypes, MailUtil::getValidTypes($type)); }
/** * Render the mail. * * @param FilterPreRenderEvent $preEvent The template pre event * @param MailInterface $mail The mail * * @return MailRendered */ protected function doRender(FilterPreRenderEvent $preEvent, MailInterface $mail) { $variables = $preEvent->getVariables(); $variables['_mail_type'] = $mail->getType(); $variables['_layout'] = null !== $mail->getLayout() ? $mail->getLayout()->getName() : null; $subject = $this->renderTemplate($mail->getSubject(), $mail, $variables); $variables['_subject'] = $subject; $htmlBody = $this->renderTemplate($mail->getHtmlBody(), $mail, $variables); $variables['_html_body'] = $htmlBody; $body = $this->renderTemplate($mail->getBody(), $mail, $variables); $variables['_body'] = $body; $layout = $this->getTranslatedLayout($mail); if (null !== $layout && null !== ($lBody = $layout->getBody()) && !MailUtil::isRootBody($htmlBody)) { $htmlBody = $this->renderTemplate($lBody, $layout, $variables); } return new MailRendered($mail, $subject, $htmlBody, $body); }
/** * {@inheritdoc} */ public function supports(MailRenderedInterface $mailRendered) { $validTypes = MailUtil::getValidTypes($mailRendered->getTemplate()->getType()); return in_array(MailTypes::TYPE_SCREEN, $validTypes); }
public function testLoad() { $template = $this->getMockBuilder(Mail::class)->disableOriginalConstructor()->getMock(); $this->repo->expects($this->once())->method('findOneBy')->with(array('name' => 'test', 'enabled' => true, 'type' => MailUtil::getValidTypes(MailTypes::TYPE_ALL)))->will($this->returnValue($template)); $this->assertSame($template, $this->loader->load('test')); }