[ Index ]

PHP Cross Reference of phpBB-3.3.5-deutsch

title

Body

[close]

/vendor/symfony/http-kernel/Event/ -> GetResponseForExceptionEvent.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\HttpKernel\Event;
  13  
  14  use Symfony\Component\HttpFoundation\Request;
  15  use Symfony\Component\HttpKernel\HttpKernelInterface;
  16  
  17  /**
  18   * Allows to create a response for a thrown exception.
  19   *
  20   * Call setResponse() to set the response that will be returned for the
  21   * current request. The propagation of this event is stopped as soon as a
  22   * response is set.
  23   *
  24   * You can also call setException() to replace the thrown exception. This
  25   * exception will be thrown if no response is set during processing of this
  26   * event.
  27   *
  28   * @author Bernhard Schussek <bschussek@gmail.com>
  29   */
  30  class GetResponseForExceptionEvent extends GetResponseEvent
  31  {
  32      /**
  33       * The exception object.
  34       *
  35       * @var \Exception
  36       */
  37      private $exception;
  38  
  39      /**
  40       * @var bool
  41       */
  42      private $allowCustomResponseCode = false;
  43  
  44      public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, \Exception $e)
  45      {
  46          parent::__construct($kernel, $request, $requestType);
  47  
  48          $this->setException($e);
  49      }
  50  
  51      /**
  52       * Returns the thrown exception.
  53       *
  54       * @return \Exception The thrown exception
  55       */
  56      public function getException()
  57      {
  58          return $this->exception;
  59      }
  60  
  61      /**
  62       * Replaces the thrown exception.
  63       *
  64       * This exception will be thrown if no response is set in the event.
  65       *
  66       * @param \Exception $exception The thrown exception
  67       */
  68      public function setException(\Exception $exception)
  69      {
  70          $this->exception = $exception;
  71      }
  72  
  73      /**
  74       * Mark the event as allowing a custom response code.
  75       */
  76      public function allowCustomResponseCode()
  77      {
  78          $this->allowCustomResponseCode = true;
  79      }
  80  
  81      /**
  82       * Returns true if the event allows a custom response code.
  83       *
  84       * @return bool
  85       */
  86      public function isAllowingCustomResponseCode()
  87      {
  88          return $this->allowCustomResponseCode;
  89      }
  90  }


Generated: Mon Oct 4 17:42:11 2021 Cross-referenced by PHPXref 0.7.1