ControllerEvent.php 1.2 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 filtering of a controller callable.
  15. *
  16. * You can call getController() to retrieve the current controller. With
  17. * setController() you can set a new controller that is used in the processing
  18. * of the request.
  19. *
  20. * Controllers should be callables.
  21. *
  22. * @author Bernhard Schussek <bschussek@gmail.com>
  23. */
  24. final class ControllerEvent extends KernelEvent
  25. {
  26. private $controller;
  27. public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, ?int $requestType)
  28. {
  29. parent::__construct($kernel, $request, $requestType);
  30. $this->setController($controller);
  31. }
  32. public function getController(): callable
  33. {
  34. return $this->controller;
  35. }
  36. public function setController(callable $controller): void
  37. {
  38. $this->controller = $controller;
  39. }
  40. }