當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FlattenException::getFile方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpKernel\Exception\FlattenException::getFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP FlattenException::getFile方法的具體用法?PHP FlattenException::getFile怎麽用?PHP FlattenException::getFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpKernel\Exception\FlattenException的用法示例。


在下文中一共展示了FlattenException::getFile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: showAction

 /**
  * Converts an Exception to a Response.
  *
  * @param Request              $request   The request
  * @param FlattenException     $exception A FlattenException instance
  * @param DebugLoggerInterface $logger    A DebugLoggerInterface instance
  *
  * @return Response
  *
  * @throws \InvalidArgumentException When the exception template does not exist
  */
 public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
 {
     $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
     $code = $exception->getStatusCode();
     if ($exception->GetClass() == 'UCI\\Boson\\ExcepcionesBundle\\Exception\\LocalException') {
         $arrayRutaFile = explode(DIRECTORY_SEPARATOR, $exception->getFile());
         $strExtraer = "";
         for ($i = count($arrayRutaFile) - 1; $i >= 0; $i--) {
             if (preg_match('/[a-zA-Z0-9]Bundle$/', $arrayRutaFile[$i]) == 1) {
                 $direccionBundle = explode($strExtraer, $exception->getFile())[0];
                 $direccionFileExcepciones = $direccionBundle . DIRECTORY_SEPARATOR . "Resources" . DIRECTORY_SEPARATOR . "config";
                 if (is_dir($direccionFileExcepciones)) {
                     break;
                 }
             }
             $strExtraer = DIRECTORY_SEPARATOR . $arrayRutaFile[$i] . $strExtraer;
         }
         $showInProd = false;
         $values = $this->getArrayExcepcionesInFile($direccionFileExcepciones);
         foreach ($values as $key => $excp) {
             if ($key == $exception->getCode() && array_key_exists('show_in_prod', $excp)) {
                 $showInProd = $excp['show_in_prod'];
             }
         }
         return new Response($this->twig->render((string) $this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug), array('status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'show_in_prod' => $showInProd, 'logger' => $logger, 'currentContent' => $currentContent)));
     }
     return new Response($this->twig->render((string) $this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug), array('status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent)));
 }
開發者ID:bosonsymfony,項目名稱:excepciones-bundle,代碼行數:39,代碼來源:ExceptionController.php

示例2: 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


注:本文中的Symfony\Component\HttpKernel\Exception\FlattenException::getFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。