Beispiel #1
0
 /**
  * Create a new mail object.
  *
  * @since 1.0.0
  *
  * @param string          $format   Optional. Format to use.
  * @param string|Template $template Optional. Template to be used.
  *
  * @return Mail
  */
 public function createMail($format = 'html', $template = 'BasicTemplate')
 {
     $mail_factory = new Factory($this->config, 'mails');
     $mail_class = $this->config->getKey('formats')[$format]['mail'];
     $mail = $mail_factory->create($mail_class);
     $mail->setTemplate($template);
     return $mail;
 }
 /**
  * Create an instance of a template.
  *
  * @since 1.0.0
  *
  * @param string $template Template to instantiate.
  *
  * @return Template $template Newly created instance.
  * @throws RuntimeException
  */
 protected function createTemplate($template)
 {
     $templateFactory = new Factory($this->config, 'templates');
     return $templateFactory->create($template, [$template, $this->viewBuilder]);
 }
 /**
  * Render the template for a given context.
  *
  * @since 1.0.0
  *
  * @param array $context The context in which to render the template.
  *
  * @return string The rendered content.
  */
 public function render(array $context)
 {
     $viewName = $this->getViewName($context);
     $view = $this->viewBuilder->create($viewName);
     $sanitizerType = $this->config['formats'][$context['format']]['sanitizer'];
     $sanitizerFactory = new Factory($this->config, 'sanitizers');
     $sanitizer = $sanitizerFactory->create($sanitizerType);
     $output = $view->render($context);
     return $sanitizer->sanitize($output, $context);
 }