菜谱项目

ControllerResolverInterface.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. interface ControllerResolverInterface
  23. {
  24. /**
  25. * Returns the Controller instance associated with a Request.
  26. *
  27. * As several resolvers can exist for a single application, a resolver must
  28. * return false when it is not able to determine the controller.
  29. *
  30. * The resolver must only throw an exception when it should be able to load
  31. * controller but cannot because of some errors made by the developer.
  32. *
  33. * @return callable|false A PHP callable representing the Controller,
  34. * or false if this resolver is not able to determine the controller
  35. *
  36. * @throws \LogicException If the controller can't be found
  37. */
  38. public function getController(Request $request);
  39. /**
  40. * Returns the arguments to pass to the controller.
  41. *
  42. * @param Request $request A Request instance
  43. * @param callable $controller A PHP callable
  44. *
  45. * @return array An array of arguments to pass to the controller
  46. *
  47. * @throws \RuntimeException When value for argument given is not provided
  48. *
  49. * @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Please use the {@see ArgumentResolverInterface} instead.
  50. */
  51. public function getArguments(Request $request, $controller);
  52. }