ControllerResolverInterface.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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\Controller;
  11. use Symfony\Component\HttpFoundation\Request;
  12. /**
  13. * A ControllerResolverInterface implementation knows how to determine the
  14. * controller to execute based on a Request object.
  15. *
  16. * It can also determine the arguments to pass to the Controller.
  17. *
  18. * A Controller can be any valid PHP callable.
  19. *
  20. * @author Fabien Potencier <fabien@symfony.com>
  21. *
  22. * @api
  23. */
  24. interface ControllerResolverInterface
  25. {
  26. /**
  27. * Returns the Controller instance associated with a Request.
  28. *
  29. * As several resolvers can exist for a single application, a resolver must
  30. * return false when it is not able to determine the controller.
  31. *
  32. * The resolver must only throw an exception when it should be able to load
  33. * controller but cannot because of some errors made by the developer.
  34. *
  35. * @param Request $request A Request instance
  36. *
  37. * @return mixed|Boolean A PHP callable representing the Controller,
  38. * or false if this resolver is not able to determine the controller
  39. *
  40. * @throws \InvalidArgumentException|\LogicException If the controller can't be found
  41. *
  42. * @api
  43. */
  44. public function getController(Request $request);
  45. /**
  46. * Returns the arguments to pass to the controller.
  47. *
  48. * @param Request $request A Request instance
  49. * @param mixed $controller A PHP callable
  50. *
  51. * @return array An array of arguments to pass to the controller
  52. *
  53. * @throws \RuntimeException When value for argument given is not provided
  54. *
  55. * @api
  56. */
  57. public function getArguments(Request $request, $controller);
  58. }