KernelEvent.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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\HttpKernel\HttpKernelInterface;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\EventDispatcher\Event;
  14. /**
  15. * Base class for events thrown in the HttpKernel component
  16. *
  17. * @author Bernhard Schussek <bschussek@gmail.com>
  18. *
  19. * @api
  20. */
  21. class KernelEvent extends Event
  22. {
  23. /**
  24. * The kernel in which this event was thrown
  25. * @var HttpKernelInterface
  26. */
  27. private $kernel;
  28. /**
  29. * The request the kernel is currently processing
  30. * @var Request
  31. */
  32. private $request;
  33. /**
  34. * The request type the kernel is currently processing. One of
  35. * HttpKernelInterface::MASTER_REQUEST and HttpKernelInterface::SUB_REQUEST
  36. * @var integer
  37. */
  38. private $requestType;
  39. public function __construct(HttpKernelInterface $kernel, Request $request, $requestType)
  40. {
  41. $this->kernel = $kernel;
  42. $this->request = $request;
  43. $this->requestType = $requestType;
  44. }
  45. /**
  46. * Returns the kernel in which this event was thrown
  47. *
  48. * @return HttpKernelInterface
  49. *
  50. * @api
  51. */
  52. public function getKernel()
  53. {
  54. return $this->kernel;
  55. }
  56. /**
  57. * Returns the request the kernel is currently processing
  58. *
  59. * @return Request
  60. *
  61. * @api
  62. */
  63. public function getRequest()
  64. {
  65. return $this->request;
  66. }
  67. /**
  68. * Returns the request type the kernel is currently processing
  69. *
  70. * @return integer One of HttpKernelInterface::MASTER_REQUEST and
  71. * HttpKernelInterface::SUB_REQUEST
  72. *
  73. * @api
  74. */
  75. public function getRequestType()
  76. {
  77. return $this->requestType;
  78. }
  79. }