ControllerArgumentsEvent.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 filtering of controller arguments.
  15. *
  16. * You can call getController() to retrieve the controller and getArguments
  17. * to retrieve the current arguments. With setArguments() you can replace
  18. * arguments that are used to call the controller.
  19. *
  20. * Arguments set in the event must be compatible with the signature of the
  21. * controller.
  22. *
  23. * @author Christophe Coevoet <stof@notk.org>
  24. */
  25. final class ControllerArgumentsEvent extends KernelEvent
  26. {
  27. private $controller;
  28. private $arguments;
  29. public function __construct(HttpKernelInterface $kernel, callable $controller, array $arguments, Request $request, ?int $requestType)
  30. {
  31. parent::__construct($kernel, $request, $requestType);
  32. $this->controller = $controller;
  33. $this->arguments = $arguments;
  34. }
  35. public function getController(): callable
  36. {
  37. return $this->controller;
  38. }
  39. public function setController(callable $controller)
  40. {
  41. $this->controller = $controller;
  42. }
  43. public function getArguments(): array
  44. {
  45. return $this->arguments;
  46. }
  47. public function setArguments(array $arguments)
  48. {
  49. $this->arguments = $arguments;
  50. }
  51. }