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


PHP GetResponseForExceptionEvent::getDispatcher方法代码示例

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


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

示例1: onKernelException

 /**
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     $statusCode = $this->getHttpStatusCode($exception->getCode());
     if ($this->application->isDebugMode()) {
         $this->response = $this->getDebugTraceResponse($exception, $statusCode);
     } else {
         $this->response = $this->getErrorPageResponse($exception, $statusCode);
     }
     $event->setResponse($this->response);
     $filterEvent = new FilterResponseEvent($event->getKernel(), $event->getRequest(), $event->getRequestType(), $event->getResponse());
     $event->getDispatcher()->dispatch(KernelEvents::RESPONSE, $filterEvent);
 }
开发者ID:backbee,项目名称:backbee,代码行数:16,代码来源:ExceptionListener.php

示例2: onKernelException

 /**
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     /** @var \appProdProjectContainer $container */
     if ($exception instanceof \SoapFault) {
         $container = $event->getDispatcher()->getContainer();
         $errorResponse = $container->get('med_coupon_service.transport.med_coupon_service_transport_api')->getTalonClientSOAP()->getCurl()->getResponse();
         //            $container->get('med_coupon_service.transport.med_coupon_service_transport_api');
         $server = new Server();
         $response = $server->getResponse(array('error' => array('code' => $exception->getCode(), 'message' => $exception->getMessage(), 'data' => $errorResponse)), array('id' => null));
         //            $response = new Response('<error>1<error>');
         echo $response;
         exit;
     }
 }
开发者ID:adminmapsoft,项目名称:timetable,代码行数:18,代码来源:ExceptionErrorListener.php

示例3: onKernelException

 /**
  * Handles security related exceptions.
  *
  * @param GetResponseForExceptionEvent $event An GetResponseForExceptionEvent instance
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     // we need to remove ourselves as the exception listener can be
     // different depending on the Request
     $event->getDispatcher()->removeListener(KernelEvents::EXCEPTION, array($this, 'onKernelException'));
     $exception = $event->getException();
     do {
         if ($exception instanceof AuthenticationException) {
             return $this->handleAuthenticationException($event, $exception);
         } elseif ($exception instanceof AccessDeniedException) {
             return $this->handleAccessDeniedException($event, $exception);
         } elseif ($exception instanceof LogoutException) {
             return $this->handleLogoutException($event, $exception);
         }
     } while (null !== ($exception = $exception->getPrevious()));
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:21,代码来源:ExceptionListener.php

示例4: onKernelException

 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     $statusCode = $exception->getCode();
     if ($this->application->isDebugMode()) {
         $this->response = (new \Symfony\Component\Debug\ExceptionHandler())->createResponse($exception);
     }
     if (!$this->application->isDebugMode()) {
         switch ($statusCode) {
             case 404:
             case 500:
                 $parameterKey = "error.{$statusCode}";
                 break;
             default:
                 $parameterKey = 'error.default';
         }
         $parameter = $this->application->getContainer()->getParameter($parameterKey);
         $view = $this->getErrorTemplate($parameter);
         $this->response->setStatusCode($statusCode)->setContent($this->renderer->partial($view, ['error' => $exception]));
     }
     $event->setResponse($this->response);
     $filterEvent = new FilterResponseEvent($event->getKernel(), $event->getRequest(), $event->getRequestType(), $event->getResponse());
     $event->getDispatcher()->dispatch(KernelEvents::RESPONSE, $filterEvent);
 }
开发者ID:nietzcheson,项目名称:BackBee,代码行数:24,代码来源:ExceptionListener.php

示例5: onKernelException

 /**
  * Handles security related exceptions.
  *
  * @param GetResponseForExceptionEvent $event An GetResponseForExceptionEvent instance
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     // we need to remove ourselves as the exception listener can be
     // different depending on the Request
     $event->getDispatcher()->removeListener(KernelEvents::EXCEPTION, array($this, 'onKernelException'));
     $exception = $event->getException();
     $request = $event->getRequest();
     // determine the actual cause for the exception
     while (null !== ($previous = $exception->getPrevious())) {
         $exception = $previous;
     }
     if ($exception instanceof AuthenticationException) {
         if (null !== $this->logger) {
             $this->logger->info(sprintf('Authentication exception occurred; redirecting to authentication entry point (%s)', $exception->getMessage()));
         }
         try {
             $response = $this->startAuthentication($request, $exception);
         } catch (\Exception $e) {
             $event->setException($e);
             return;
         }
     } elseif ($exception instanceof AccessDeniedException) {
         $event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
         $token = $this->context->getToken();
         if (!$this->authenticationTrustResolver->isFullFledged($token)) {
             if (null !== $this->logger) {
                 $this->logger->debug(sprintf('Access is denied (user is not fully authenticated) by "%s" at line %s; redirecting to authentication entry point', $exception->getFile(), $exception->getLine()));
             }
             try {
                 $insufficientAuthenticationException = new InsufficientAuthenticationException('Full authentication is required to access this resource.', 0, $exception);
                 $insufficientAuthenticationException->setToken($token);
                 $response = $this->startAuthentication($request, $insufficientAuthenticationException);
             } catch (\Exception $e) {
                 $event->setException($e);
                 return;
             }
         } else {
             if (null !== $this->logger) {
                 $this->logger->debug(sprintf('Access is denied (and user is neither anonymous, nor remember-me) by "%s" at line %s', $exception->getFile(), $exception->getLine()));
             }
             try {
                 if (null !== $this->accessDeniedHandler) {
                     $response = $this->accessDeniedHandler->handle($request, $exception);
                     if (!$response instanceof Response) {
                         return;
                     }
                 } elseif (null !== $this->errorPage) {
                     $subRequest = $this->httpUtils->createRequest($request, $this->errorPage);
                     $subRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR, $exception);
                     $response = $event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
                 } else {
                     return;
                 }
             } catch (\Exception $e) {
                 if (null !== $this->logger) {
                     $this->logger->error(sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()));
                 }
                 $event->setException(new \RuntimeException('Exception thrown when handling an exception.', 0, $e));
                 return;
             }
         }
     } elseif ($exception instanceof LogoutException) {
         if (null !== $this->logger) {
             $this->logger->info(sprintf('Logout exception occurred; wrapping with AccessDeniedHttpException (%s)', $exception->getMessage()));
         }
         return;
     } else {
         return;
     }
     $event->setResponse($response);
 }
开发者ID:senthil-r-wiredelta,项目名称:meilleure-visite,代码行数:76,代码来源:ExceptionListener.php


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