function it_falls_back_to_defaults_during_rendering_when_necessary(MailInterface $mail, FilterChainInterface $filterChain)
 {
     $this->addMapping(new DefaultMapping());
     $mail->addParameter(Argument::any(), Argument::any())->willReturn(null);
     $mail->getTemplate()->willReturn('test');
     $mail->transform(Argument::type('Symfony\\Component\\Templating\\EngineInterface'), $filterChain, array(array('view' => DefaultMapping::VIEW, 'contentType' => DefaultMapping::CONTENT_TYPE)))->willReturn(new \Swift_Message());
     $message = $this->render($mail);
     $message->shouldHaveType('\\Swift_Message');
 }
Ejemplo n.º 2
0
 /**
  * {@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);
 }