/** * {@inheritdoc} * * If no template is found, it falls back to default template */ public function render(MailInterface $mail) { $templates = $this->getViewData($mail->getTemplate()); // Set default content type for each template, if not present foreach ($templates as &$template) { if (!isset($template['contentType'])) { $template['contentType'] = $this->defaultContentType; } } // Adds default email parameters to the view foreach ($this->emailParameters as $name => $value) { $mail->addParameter($name, $value); } return $mail->transform($this->templating, $this->filterChain, $templates); }
function it_throws_exception_during_rendering_when_no_default_template_found(MailInterface $mail) { $mail->getTemplate()->willReturn('test'); $this->shouldThrow('Ahlin\\Mailer\\Exception\\MailerException')->duringRender($mail); }