Пример #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
 /**
  * helper function allowing you to render a template using a template engine
  *
  * @param string $templateName the template path of the template
  * @param array  $parameters   an array of parameters to assign to a template engine
  *
  * @return string the content generated by a template engine
  */
 public function render($templateName, array $parameters = array())
 {
     $templateDir = $this->assetsResolver->resolveAssetSourcePath($this->module->getCode(), false, $templateName, $this->parser);
     if (null !== $templateDir) {
         // retrieve the template
         $content = $this->parser->render($templateDir . DS . $templateName, $parameters);
     } else {
         $content = sprintf("ERR: Unknown template %s for module %s", $templateName, $this->module->getCode());
     }
     return $content;
 }
Пример #4
0
 /**
  * Calculate the message body, given the HTML entered in the back-office, the message layout, and the message template
  * @param  ParserInterface $parser
  * @param $message
  * @param $layout
  * @param $template
  * @return bool
  */
 protected function getMessageBody($parser, $message, $layout, $template, $compressOutput = true)
 {
     $body = false;
     // Try to get the body from template file, if a file is defined
     if (!empty($template)) {
         try {
             $body = $parser->render($template, [], $compressOutput);
         } catch (ResourceNotFoundException $ex) {
             // Ignore this.
         }
     }
     // We did not get it ? Use the message entered in the back-office
     if ($body === false) {
         $body = $parser->renderString($message, [], $compressOutput);
     }
     // Do we have a layout ?
     if (!empty($layout)) {
         // Populate the message body variable
         $parser->assign('message_body', $body);
         // Render the layout file
         $body = $parser->render($layout, [], $compressOutput);
     }
     return $body;
 }