GetResponseForControllerResultEvent.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /**
  14. * Allows to create a response for the return value of a controller
  15. *
  16. * Call setResponse() to set the response that will be returned for the
  17. * current request. The propagation of this event is stopped as soon as a
  18. * response is set.
  19. *
  20. * @author Bernhard Schussek <bschussek@gmail.com>
  21. *
  22. * @api
  23. */
  24. class GetResponseForControllerResultEvent extends GetResponseEvent
  25. {
  26. /**
  27. * The return value of the controller
  28. *
  29. * @var mixed
  30. */
  31. private $controllerResult;
  32. public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, $controllerResult)
  33. {
  34. parent::__construct($kernel, $request, $requestType);
  35. $this->controllerResult = $controllerResult;
  36. }
  37. /**
  38. * Returns the return value of the controller.
  39. *
  40. * @return mixed The controller return value
  41. *
  42. * @api
  43. */
  44. public function getControllerResult()
  45. {
  46. return $this->controllerResult;
  47. }
  48. /**
  49. * Assigns the return value of the controller.
  50. *
  51. * @param mixed The controller return value
  52. *
  53. * @api
  54. */
  55. public function setControllerResult($controllerResult)
  56. {
  57. $this->controllerResult = $controllerResult;
  58. }
  59. }