Dashboard sipadu mbip
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

GetResponseForExceptionEvent.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\Event;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpKernel\HttpKernelInterface;
  13. /**
  14. * @deprecated since Symfony 4.3, use ExceptionEvent instead
  15. */
  16. class GetResponseForExceptionEvent extends RequestEvent
  17. {
  18. /**
  19. * The exception object.
  20. *
  21. * @var \Exception
  22. */
  23. private $exception;
  24. /**
  25. * @var bool
  26. */
  27. private $allowCustomResponseCode = false;
  28. public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, \Exception $e)
  29. {
  30. parent::__construct($kernel, $request, $requestType);
  31. $this->setException($e);
  32. }
  33. /**
  34. * Returns the thrown exception.
  35. *
  36. * @return \Exception The thrown exception
  37. */
  38. public function getException()
  39. {
  40. return $this->exception;
  41. }
  42. /**
  43. * Replaces the thrown exception.
  44. *
  45. * This exception will be thrown if no response is set in the event.
  46. *
  47. * @param \Exception $exception The thrown exception
  48. */
  49. public function setException(\Exception $exception)
  50. {
  51. $this->exception = $exception;
  52. }
  53. /**
  54. * Mark the event as allowing a custom response code.
  55. */
  56. public function allowCustomResponseCode()
  57. {
  58. $this->allowCustomResponseCode = true;
  59. }
  60. /**
  61. * Returns true if the event allows a custom response code.
  62. *
  63. * @return bool
  64. */
  65. public function isAllowingCustomResponseCode()
  66. {
  67. return $this->allowCustomResponseCode;
  68. }
  69. }