コード例 #1
0
 /**
  * Get the translated layout.
  *
  * @param string $layout The name of layout
  *
  * @return TwigLayout
  *
  * @throws UnknownLayoutException   When the layout template does not exist
  * @throws InvalidArgumentException When the layout is not a twig layout
  */
 public function getTranslatedLayout($layout)
 {
     $template = $this->layoutLoader->load($layout);
     $template = TranslationUtil::translateLayout($template, $this->getTemplater()->getLocale(), $this->translator);
     if (!$template instanceof TwigLayout) {
         $msg = 'The "%s" layout is not a twig layout';
         throw new InvalidArgumentException(sprintf($msg, $layout));
     }
     return $template;
 }
コード例 #2
0
 /**
  * Create the mail.
  *
  * @param array $config
  *
  * @return MailInterface
  */
 protected function createMail(array $config)
 {
     $mail = $this->newMailInstance();
     $mail->setName(ConfigUtil::getValue($config, 'name'));
     $mail->setLabel(ConfigUtil::getValue($config, 'label'));
     $mail->setDescription(ConfigUtil::getValue($config, 'description'));
     $mail->setType(ConfigUtil::getValue($config, 'type', MailTypes::TYPE_ALL));
     $mail->setEnabled(ConfigUtil::getValue($config, 'enabled', true));
     $mail->setSubject(ConfigUtil::getValue($config, 'subject'));
     $mail->setHtmlBody(ConfigUtil::getValue($config, 'html_body'));
     $mail->setBody(ConfigUtil::getValue($config, 'body'));
     $mail->setTranslationDomain(ConfigUtil::getValue($config, 'translation_domain'));
     if (isset($config['layout'])) {
         $mail->setLayout($this->layoutLoader->load($config['layout']));
     }
     if (isset($config['translations']) && is_array($config['translations'])) {
         foreach ($config['translations'] as $translation) {
             $mail->addTranslation($this->createMailTranslation($mail, $translation));
         }
     }
     return $mail;
 }