Пример #1
0
 protected function display404(GetResponseForExceptionEvent $event)
 {
     // Define the template thant shoud be used
     $this->parser->setTemplateDefinition($this->parser->getTemplateHelper()->getActiveFrontTemplate());
     $response = new Response($this->parser->render(ConfigQuery::getPageNotFoundView()), 404);
     $event->setResponse($response);
 }
Пример #2
0
 public function defaultErrorFallback(GetResponseForExceptionEvent $event)
 {
     $this->parser->assign("status_code", 500);
     $this->parser->assign("exception_message", $event->getException()->getMessage());
     $this->parser->setTemplateDefinition($this->securityContext->hasAdminUser() ? $this->parser->getTemplateHelper()->getActiveAdminTemplate() : $this->parser->getTemplateHelper()->getActiveFrontTemplate());
     $response = new Response($this->parser->render(ConfigQuery::getErrorMessagePageName()), 500);
     $event->setResponse($response);
 }
Пример #3
0
 /**
  * Add a subject and a body (TEXT, HTML or both, depending on the message
  * configuration.
  *
  * @param  ParserInterface $parser
  * @param  \Swift_Message  $messageInstance
  * @param  bool            $useFallbackTemplate When we send mail from a module and don't use the `default` email
  *                                              template, if the file (html/txt) is not found in the template then
  *                                              the template file located in the module under
  *                                              `templates/email/default/' directory is used if
  *                                              `$useFallbackTemplate` is set to `true`.
  */
 public function buildMessage(ParserInterface $parser, \Swift_Message $messageInstance, $useFallbackTemplate = true)
 {
     $parser->setTemplateDefinition($parser->getTemplateHelper()->getActiveMailTemplate(), $useFallbackTemplate);
     $subject = $parser->fetch(sprintf("string:%s", $this->getSubject()));
     $htmlMessage = $this->getHtmlMessageBody($parser);
     $textMessage = $this->getTextMessageBody($parser);
     $messageInstance->setSubject($subject);
     // If we do not have an HTML message
     if (empty($htmlMessage)) {
         // Message body is the text message
         $messageInstance->setBody($textMessage, 'text/plain');
     } else {
         // The main body is the HTML messahe
         $messageInstance->setBody($htmlMessage, 'text/html');
         // Use the text as a message part, if we have one.
         if (!empty($textMessage)) {
             $messageInstance->addPart($textMessage, 'text/plain');
         }
     }
     return $messageInstance;
 }