コード例 #1
0
ファイル: ExceptionController.php プロジェクト: rmanasyan/swe
 protected function findTemplate($templating, $format, $code, $debug)
 {
     if (!$debug && $this->exceptionClass == 'Yoda\\EventBundle\\Exception\\EventNotFoundHttpException') {
         return 'EventBundle:Exception:event404.html.twig';
     }
     return parent::findTemplate($templating, $format, $code, $debug);
 }
コード例 #2
0
 /**
  * @param Request $request
  * @param string  $format
  * @param int     $code
  * @param bool    $debug
  *
  * @return TemplateReference
  */
 protected function findTemplate(Request $request, $format, $code, $debug)
 {
     if (strpos($request->getPathInfo(), '/admin') !== 0) {
         return parent::findTemplate($request, $format, $code, $debug);
     }
     $name = $debug ? 'exception' : 'error';
     if ($debug && 'html' == $format) {
         $name = 'exception_full';
     }
     // when not in debug, try to find a template for the specific HTTP status code and format
     if (!$debug) {
         $template = new TemplateReference('AvanzuAdminThemeBundle', 'Exception', $name . $code, $format, 'twig');
         if ($this->templateExists($template)) {
             return $template;
         }
     }
     // try to find a template for the given format
     $template = new TemplateReference('AvanzuAdminThemeBundle', 'Exception', $name, $format, 'twig');
     if ($this->templateExists($template)) {
         return $template;
     }
     // default to a generic HTML exception
     $request->setRequestFormat('html');
     $template = new TemplateReference('AvanzuAdminThemeBundle', 'Exception', $name, 'html', 'twig');
     if ($this->templateExists($template)) {
         return $template;
     }
     return parent::findTemplate($request, $format, $code, $debug);
 }
コード例 #3
0
 /**
  * @param Request $request
  * @param string  $format
  * @param int     $code          An HTTP response status code
  * @param bool    $showException
  *
  * @return string
  */
 protected function findTemplate(Request $request, $format, $code, $showException)
 {
     if (!$showException) {
         if ($this->templateExists($this->exceptionTemplate)) {
             return $this->exceptionTemplate;
         }
     }
     return parent::findTemplate($request, $format, $code, $showException);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 protected function findTemplate(Request $request, $format, $code, $debug)
 {
     if (!$debug && $format === 'html') {
         $code = in_array($code, array(400, 403, 404, 503)) ? $code : 500;
         $template = new TemplateReference('ClarolineCoreBundle', 'Exception', 'error' . $code, 'html', 'twig');
         if ($this->templateExists($template)) {
             return $template;
         }
     }
     return parent::findTemplate($request, $format, $code, $debug);
 }
コード例 #5
0
 protected function findTemplate(Request $request, $format, $code, $showException)
 {
     $template = parent::findTemplate($request, $format, $code, $showException);
     // Only customize error display for PJAX requests.
     if (!$request->headers->has('X-PJAX')) {
         return $template;
     }
     $customTemplate = clone $template;
     $customTemplate->set('bundle', 'eZPlatformUIBundle');
     if ($this->templateExists($customTemplate)) {
         return $customTemplate;
     }
     return $template;
 }
コード例 #6
0
 protected function findTemplate($templating, $format, $code, $debug)
 {
     if ($debug) {
         // debug
         return parent::findTemplate($templating, $format, $code, $debug);
     }
     if ($this->request->server->has('PATH_INFO')) {
         $pathInfo = $this->request->server->get('PATH_INFO');
     } else {
         $pathInfo = $this->request->server->get('REQUEST_URI');
     }
     // check if this path is /admin/
     if (\preg_match('/^\\/admin\\//', $pathInfo)) {
         $template = new TemplateReference('AdminBundle', 'Exception', 'error', 'html', 'twig');
     } elseif (\preg_match('/^\\/institution\\//', $pathInfo)) {
         $template = new TemplateReference('InstitutionBundle', 'Exception', 'error', 'html', 'twig');
     } else {
         // assume we are in frontend
         $template = new TemplateReference('FrontendBundle', 'Exception', 'error', 'html', 'twig');
     }
     if ($templating->exists($template)) {
         return $template;
     }
 }
コード例 #7
0
 /**
  * Return the template for rendering a status code
  *
  * @param Request $request
  * @param string  $format
  * @param integer $code          Status code to locate a template
  * @param bool    $showException
  *
  * @return TemplateReferenceInterface
  */
 protected function findTemplate(Request $request, $format, $code, $showException)
 {
     if (!$this->supports($request)) {
         return parent::findTemplate($request, $format, $code, $showException);
     }
     return $this->templateLocator->locate(isset($this->templateByCode[$code]) ? $this->templateByCode[$code] : $this->defaultTemplate);
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 protected function findTemplate(Request $request, $format, $code, $showException)
 {
     $this->request = $request;
     return parent::findTemplate($request, $format, $code, $showException);
 }