You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.0 KiB

3 years ago
  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;
  11. use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
  12. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  13. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  14. use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
  15. use Symfony\Component\HttpKernel\Event\RequestEvent;
  16. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  17. use Symfony\Component\HttpKernel\Event\TerminateEvent;
  18. use Symfony\Component\HttpKernel\Event\ViewEvent;
  19. /**
  20. * Contains all events thrown in the HttpKernel component.
  21. *
  22. * @author Bernhard Schussek <bschussek@gmail.com>
  23. */
  24. final class KernelEvents
  25. {
  26. /**
  27. * The REQUEST event occurs at the very beginning of request
  28. * dispatching.
  29. *
  30. * This event allows you to create a response for a request before any
  31. * other code in the framework is executed.
  32. *
  33. * @Event("Symfony\Component\HttpKernel\Event\RequestEvent")
  34. */
  35. public const REQUEST = 'kernel.request';
  36. /**
  37. * The EXCEPTION event occurs when an uncaught exception appears.
  38. *
  39. * This event allows you to create a response for a thrown exception or
  40. * to modify the thrown exception.
  41. *
  42. * @Event("Symfony\Component\HttpKernel\Event\ExceptionEvent")
  43. */
  44. public const EXCEPTION = 'kernel.exception';
  45. /**
  46. * The CONTROLLER event occurs once a controller was found for
  47. * handling a request.
  48. *
  49. * This event allows you to change the controller that will handle the
  50. * request.
  51. *
  52. * @Event("Symfony\Component\HttpKernel\Event\ControllerEvent")
  53. */
  54. public const CONTROLLER = 'kernel.controller';
  55. /**
  56. * The CONTROLLER_ARGUMENTS event occurs once controller arguments have been resolved.
  57. *
  58. * This event allows you to change the arguments that will be passed to
  59. * the controller.
  60. *
  61. * @Event("Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent")
  62. */
  63. public const CONTROLLER_ARGUMENTS = 'kernel.controller_arguments';
  64. /**
  65. * The VIEW event occurs when the return value of a controller
  66. * is not a Response instance.
  67. *
  68. * This event allows you to create a response for the return value of the
  69. * controller.
  70. *
  71. * @Event("Symfony\Component\HttpKernel\Event\ViewEvent")
  72. */
  73. public const VIEW = 'kernel.view';
  74. /**
  75. * The RESPONSE event occurs once a response was created for
  76. * replying to a request.
  77. *
  78. * This event allows you to modify or replace the response that will be
  79. * replied.
  80. *
  81. * @Event("Symfony\Component\HttpKernel\Event\ResponseEvent")
  82. */
  83. public const RESPONSE = 'kernel.response';
  84. /**
  85. * The FINISH_REQUEST event occurs when a response was generated for a request.
  86. *
  87. * This event allows you to reset the global and environmental state of
  88. * the application, when it was changed during the request.
  89. *
  90. * @Event("Symfony\Component\HttpKernel\Event\FinishRequestEvent")
  91. */
  92. public const FINISH_REQUEST = 'kernel.finish_request';
  93. /**
  94. * The TERMINATE event occurs once a response was sent.
  95. *
  96. * This event allows you to run expensive post-response jobs.
  97. *
  98. * @Event("Symfony\Component\HttpKernel\Event\TerminateEvent")
  99. */
  100. public const TERMINATE = 'kernel.terminate';
  101. /**
  102. * Event aliases.
  103. *
  104. * These aliases can be consumed by RegisterListenersPass.
  105. */
  106. public const ALIASES = [
  107. ControllerArgumentsEvent::class => self::CONTROLLER_ARGUMENTS,
  108. ControllerEvent::class => self::CONTROLLER,
  109. ResponseEvent::class => self::RESPONSE,
  110. FinishRequestEvent::class => self::FINISH_REQUEST,
  111. RequestEvent::class => self::REQUEST,
  112. ViewEvent::class => self::VIEW,
  113. ExceptionEvent::class => self::EXCEPTION,
  114. TerminateEvent::class => self::TERMINATE,
  115. ];
  116. }