/**
  * @param Nette\Application\UI\ITemplate $template
  */
 public function configure(Nette\Application\UI\ITemplate $template)
 {
     if (!$template instanceof Nette\Bridges\ApplicationLatte\Template) {
         return;
     }
     $latte = $template->getLatte();
     if ($this->translator) {
         $template->setTranslator($this->translator);
     }
     foreach ($this->providers as $name => $provider) {
         $latte->addProvider($name, $provider);
     }
     foreach ($this->filters as $name => $filter) {
         $template->addFilter($name, $filter);
     }
     $template->setParameters($this->parameters);
 }
Exemplo n.º 2
0
 /**
  * Render latte template to string and send (and/or log) mail
  * @return void
  */
 public function send()
 {
     /**
      * Set template variables
      */
     $this->setTemplateVariables();
     /**
      * Set body/html body
      */
     try {
         $this->template->setFile($this->getTemplateFile());
         if (version_compare(Latte\Engine::VERSION, '2.4.0', '>=')) {
             $this->template->getLatte()->addProvider('uiControl', $this->linkGenerator);
         } else {
             $this->template->_control = $this->linkGenerator;
         }
         $this->message->setHtmlBody((string) $this->template, $this->mail_images_base_path);
     } catch (MailingException $e) {
         /**
          * If mail template was set and not found, bubble exception up
          */
         if ($this->template_file) {
             throw $e;
         }
         /**
          * Otherwise just suppose that user has set message body via ::setBody
          */
     }
     /**
      * In case mail sending in on, send message
      */
     if ($this->config === self::CONFIG_BOTH || $this->config === self::CONFIG_SEND) {
         $this->mailer->send($this->message);
     }
     /**
      * In case mail logging is turned on, log message
      */
     if ($this->config === self::CONFIG_LOG || $this->config === self::CONFIG_BOTH) {
         $this->logger->log($this->log_type, $this->message);
     }
 }