ViewEvent.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. * 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. final class ViewEvent extends RequestEvent
  23. {
  24. public readonly ?ControllerArgumentsEvent $controllerArgumentsEvent;
  25. private mixed $controllerResult;
  26. public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, mixed $controllerResult, ?ControllerArgumentsEvent $controllerArgumentsEvent = null)
  27. {
  28. parent::__construct($kernel, $request, $requestType);
  29. $this->controllerResult = $controllerResult;
  30. $this->controllerArgumentsEvent = $controllerArgumentsEvent;
  31. }
  32. public function getControllerResult(): mixed
  33. {
  34. return $this->controllerResult;
  35. }
  36. public function setControllerResult(mixed $controllerResult): void
  37. {
  38. $this->controllerResult = $controllerResult;
  39. }
  40. }