Exemple #1
0
 /**
  * @param $templateName
  *
  * @return EmailService
  *
  * @throws \Exception
  */
 public function setTemplate($templateName)
 {
     $this->template = $this->generalService->findWebInfoByInfo($templateName);
     if (is_null($this->template)) {
         throw new \InvalidArgumentException(sprintf('There is no no template with info "%s"', $templateName));
     }
     if (is_null($this->email)) {
         throw new \RuntimeException("The email object is empty. Did you call create() first?");
     }
     $this->email->setMessage($this->createTwigTemplate($this->template->getContent()));
     $this->email->setSubject($this->template->getSubject());
     return $this;
 }