/**
  * {@inheritdoc}
  */
 protected function createLayoutTranslation(LayoutInterface $layout, array $config)
 {
     /* @var $translation TwigLayoutTranslation */
     $translation = parent::createLayoutTranslation($layout, $config);
     $translation->setFile(ConfigUtil::getValue($config, 'file'));
     return $translation;
 }
 /**
  * {@inheritdoc}
  */
 protected function createMailTranslation(MailInterface $mail, array $config)
 {
     /* @var $translation TwigMailTranslation */
     $translation = parent::createMailTranslation($mail, $config);
     $translation->setFile(ConfigUtil::getValue($config, 'file'));
     return $translation;
 }
 /**
  * Create a layout translation.
  *
  * @param LayoutInterface $layout The layout
  * @param array           $config The config of layout translation
  *
  * @return LayoutTranslation
  */
 protected function createLayoutTranslation(LayoutInterface $layout, array $config)
 {
     $translation = $this->newLayoutTranslationInstance($layout);
     $translation->setLocale(ConfigUtil::getValue($config, 'locale'));
     $translation->setLabel(ConfigUtil::getValue($config, 'label'));
     $translation->setDescription(ConfigUtil::getValue($config, 'description'));
     $translation->setBody(ConfigUtil::getValue($config, 'body'));
     return $translation;
 }
 /**
  * {@inheritdoc}
  */
 public function load($name, $type = MailTypes::TYPE_ALL)
 {
     if (is_array($this->resources)) {
         foreach ($this->resources as $resource) {
             $config = ConfigUtil::formatTranslationConfig($resource, $this->kernel);
             $this->addMail($this->createMail($config));
         }
         $this->resources = null;
     }
     return parent::load($name, $type);
 }
 /**
  * {@inheritdoc}
  */
 public function load($name)
 {
     if (is_array($this->resources)) {
         foreach ($this->resources as $resource) {
             $config = ConfigUtil::formatTranslationConfig($resource, $this->kernel);
             $this->addLayout($this->createLayout($config));
         }
         $this->resources = null;
     }
     return parent::load($name);
 }
 /**
  * {@inheritdoc}
  */
 public function load($name, $type = MailTypes::TYPE_ALL)
 {
     if (is_array($this->resources)) {
         foreach ($this->resources as $resource) {
             $config = ConfigUtil::formatConfig($resource);
             $filename = $this->kernel->locateResource($resource);
             $loadedConfig = Yaml::parse(file_get_contents($filename));
             $this->addMail($this->createMail(array_replace($loadedConfig, $config)));
         }
         $this->resources = null;
     }
     return parent::load($name, $type);
 }
 /**
  * {@inheritdoc}
  */
 public function load($name)
 {
     if (is_array($this->resources)) {
         foreach ($this->resources as $resource) {
             $config = ConfigUtil::formatConfig($resource);
             $filename = $this->kernel->locateResource($config['file']);
             $loadedConfig = Yaml::parse(file_get_contents($filename));
             $this->addLayout($this->createLayout(array_replace($loadedConfig, $config)));
         }
         $this->resources = null;
     }
     return parent::load($name);
 }
 /**
  * @expectedException \Sonatra\Bundle\MailerBundle\Exception\InvalidConfigurationException
  * @expectedExceptionMessage The "file" attribute must be defined in config of layout template
  */
 public function testFormatConfigWithInvalidFilename()
 {
     $config = array('name' => 'test');
     ConfigUtil::formatConfig($config);
 }
 /**
  * Create a mail translation.
  *
  * @param MailInterface $mail   The mail
  * @param array         $config The config of mail translation
  *
  * @return MailTranslationInterface
  */
 protected function createMailTranslation(MailInterface $mail, array $config)
 {
     $translation = $this->newMailTranslationInstance($mail);
     $translation->setLocale(ConfigUtil::getValue($config, 'locale'));
     $translation->setLabel(ConfigUtil::getValue($config, 'label'));
     $translation->setDescription(ConfigUtil::getValue($config, 'description'));
     $translation->setSubject(ConfigUtil::getValue($config, 'subject'));
     $translation->setHtmlBody(ConfigUtil::getValue($config, 'html_body'));
     $translation->setBody(ConfigUtil::getValue($config, 'body'));
     return $translation;
 }