当前位置: 首页>>代码示例>>PHP>>正文


PHP FlattenException::getHeaders方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpKernel\Exception\FlattenException::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP FlattenException::getHeaders方法的具体用法?PHP FlattenException::getHeaders怎么用?PHP FlattenException::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpKernel\Exception\FlattenException的用法示例。


在下文中一共展示了FlattenException::getHeaders方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showAction

 /**
  * Converts an Exception to a Response.
  *
  * @param FlattenException     $exception A FlattenException instance
  * @param DebugLoggerInterface $logger    A DebugLoggerInterface instance
  * @param string               $format    The format to use for rendering (html, xml, ...)
  *
  * @throws \InvalidArgumentException When the exception template does not exist
  */
 public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $this->container->get('request')->setRequestFormat($format);
     $code = $exception->getStatusCode();
     $params = array('status_code' => $code, 'status_text' => Response::$statusTexts[$code]);
     try {
         $params['auth'] = $this->container->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED');
     } catch (\Exception $e) {
         $params['auth'] = false;
     }
     $templating = $this->container->get('templating');
     if (404 == $code) {
         if ($this->container->get('request')->isXmlHttpRequest()) {
             $response = new Response('You should not do that.');
         } else {
             $response = $templating->renderResponse('LichessBundle:Exception:notFound.html.twig', $params);
         }
     } else {
         if ($this->container->get('request')->isXmlHttpRequest()) {
             $response = new Response('Something went terribly wrong.');
         } else {
             $params['url'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['REQUEST_URI'];
             $response = $templating->renderResponse('LichessBundle:Exception:error.html.twig', $params);
         }
     }
     $response->setStatusCode($code);
     $response->headers->replace($exception->getHeaders());
     return $response;
 }
开发者ID:hafeez3000,项目名称:lichess,代码行数:38,代码来源:ExceptionController.php

示例2: showAction

    /**
     * Converts an Exception to a Response.
     *
     * @param FlattenException     $exception A FlattenException instance
     * @param DebugLoggerInterface $logger    A DebugLoggerInterface instance
     * @param string               $format    The format to use for rendering (html, xml, ...)
     *
     * @throws \InvalidArgumentException When the exception template does not exist
     */
    public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
    {
        $this->container->get('request')->setRequestFormat($format);

        // the count variable avoids an infinite loop on
        // some Windows configurations where ob_get_level()
        // never reaches 0
        $count = 100;
        $currentContent = '';
        while (ob_get_level() && --$count) {
            $currentContent .= ob_get_clean();
        }

        $templating = $this->container->get('templating');
        $code = $exception->getStatusCode();

        $response = $templating->renderResponse(
            $this->findTemplate($templating, $format, $code, $this->container->get('kernel')->isDebug()),
            array(
                'status_code'    => $code,
                'status_text'    => Response::$statusTexts[$code],
                'exception'      => $exception,
                'logger'         => $logger,
                'currentContent' => $currentContent,
            )
        );

        $response->setStatusCode($code);
        $response->headers->replace($exception->getHeaders());

        return $response;
    }
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:41,代码来源:ExceptionController.php

示例3: showAction

 /**
  * Converts an Exception to a Response.
  *
  * @param FlattenException     $exception A FlattenException instance
  * @param DebugLoggerInterface $logger    A DebugLoggerInterface instance
  * @param string               $format    The format to use for rendering (html, xml, ...)
  *
  * @throws \InvalidArgumentException When the exception template does not exist
  */
 public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $this->container->get('request')->setRequestFormat($format);
     // the count variable avoids an infinite loop on
     // some Windows configurations where ob_get_level()
     // never reaches 0
     $count = 100;
     $currentContent = '';
     while (ob_get_level() && --$count) {
         $currentContent .= ob_get_clean();
     }
     $name = $this->container->get('kernel')->isDebug() ? 'exception' : 'error';
     if ($this->container->get('kernel')->isDebug() && 'html' == $format) {
         $name = 'exception_full';
     }
     $template = 'FrameworkBundle:Exception:' . $name . '.' . $format . '.twig';
     $templating = $this->container->get('templating');
     if (!$templating->exists($template)) {
         $this->container->get('request')->setRequestFormat('html');
         $template = 'FrameworkBundle:Exception:' . $name . '.html.twig';
     }
     $code = $exception->getStatusCode();
     $response = $templating->renderResponse($template, array('status_code' => $code, 'status_text' => Response::$statusTexts[$code], 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent));
     $response->setStatusCode($code);
     $response->headers->replace($exception->getHeaders());
     return $response;
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:36,代码来源:ExceptionController.php

示例4: showAction

 public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $statusCode = $exception->getStatusCode();
     $statusText = $exception->getMessage();
     $response = $this->render('GitonomyWebsiteBundle:Error:error.html.twig', array('status_code' => $statusCode, 'status_text' => $statusText));
     $response->setStatusCode($statusCode);
     $response->headers->replace($exception->getHeaders());
     return $response;
 }
开发者ID:phecho,项目名称:gitonomy,代码行数:9,代码来源:ErrorController.php

示例5: errorAction

 public function errorAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $this->container->get('request')->setRequestFormat($format);
     $response = new Response('Something is wrong');
     $code = $exception->getStatusCode();
     $response->setStatusCode($code);
     $response->headers->replace($exception->getHeaders());
     return $response;
 }
开发者ID:hafeez3000,项目名称:lichess,代码行数:9,代码来源:SyncController.php

示例6: showAction

 /**
  * Converts an Exception to a Response.
  *
  * @param FlattenException     $exception A FlattenException instance
  * @param DebugLoggerInterface $logger    A DebugLoggerInterface instance
  * @param string               $format    The format to use for rendering (html, xml, ...)
  *
  * @return Response
  *
  * @throws \InvalidArgumentException When the exception template does not exist
  */
 public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $this->container->get('request')->setRequestFormat($format);
     $currentContent = $this->getAndCleanOutputBuffering();
     $templating = $this->container->get('templating');
     $code = $exception->getStatusCode();
     $response = $templating->renderResponse($this->findTemplate($templating, $format, $code, $this->container->get('kernel')->isDebug()), array('status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent));
     $response->setStatusCode($code);
     $response->headers->replace($exception->getHeaders());
     return $response;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:22,代码来源:ExceptionController.php

示例7: showAction

 /**
  * @param Request $request
  * @param FlattenException $exception
  * @param DebugLoggerInterface $logger
  * @return \GoIntegro\Hateoas\Http\JsonResponse
  */
 public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = NULL)
 {
     $error = new ErrorObject();
     $error->status = $exception->getStatusCode();
     $error->title = $exception->getMessage();
     $error->code = $exception->getCode();
     $serializer = new ErrorSerializer($error);
     if (500 == $error->status && NULL != $logger) {
         $logger->error(sprintf(self::ERROR_LOG_MESSAGE_PATTERN, $error->title, $exception->getFile(), $exception->getLine(), $error->id));
     }
     return $this->createNoCacheResponse($serializer->serialize(), $error->status, $exception->getHeaders());
 }
开发者ID:mb3rnard,项目名称:hateoas-bundle,代码行数:18,代码来源:ExceptionController.php

示例8: showAction

 /**
  * Converts an Exception to a Response.
  *
  * @param FlattenException     $exception A FlattenException instance
  * @param DebugLoggerInterface $logger    A DebugLoggerInterface instance
  * @param string               $format    The format to use for rendering (html, xml, ...)
  *
  * @throws \InvalidArgumentException When the exception template does not exist
  */
 public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $this->container->get('request')->setRequestFormat($format);
     $code = $exception->getStatusCode();
     $params = array('status_code' => $code, 'status_text' => Response::$statusTexts[$code]);
     if (404 == $code) {
         if ($this->container->get('request')->isXmlHttpRequest()) {
             $response = new Response('You should not do that.');
         } else {
             $response = $this->container->get('http_kernel')->forward('LichessOpeningBundle:Hook:index');
         }
     } else {
         if ($this->container->get('request')->isXmlHttpRequest()) {
             $response = new Response('Something went terribly wrong.');
         } else {
             $params['url'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['REQUEST_URI'];
             $response = $this->container->get('templating')->renderResponse('LichessBundle:Exception:error.html.twig', $params);
         }
     }
     $response->setStatusCode($code);
     $response->headers->replace($exception->getHeaders());
     return $response;
 }
开发者ID:hotfics,项目名称:lichess-old,代码行数:32,代码来源:ExceptionController.php


注:本文中的Symfony\Component\HttpKernel\Exception\FlattenException::getHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。