Drupal investigation

RouteProviderInterface.php 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /*
  3. * This file is part of the Symfony CMF package.
  4. *
  5. * (c) 2011-2015 Symfony CMF
  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\Cmf\Component\Routing;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\Routing\Exception\RouteNotFoundException;
  13. use Symfony\Component\Routing\Route;
  14. use Symfony\Component\Routing\RouteCollection;
  15. /**
  16. * Interface for the route provider the DynamicRouter is using.
  17. *
  18. * Typically this could be a doctrine orm or odm repository, but you can
  19. * implement something else if you need to.
  20. */
  21. interface RouteProviderInterface
  22. {
  23. /**
  24. * Finds routes that may potentially match the request.
  25. *
  26. * This may return a mixed list of class instances, but all routes returned
  27. * must extend the core symfony route. The classes may also implement
  28. * RouteObjectInterface to link to a content document.
  29. *
  30. * This method may not throw an exception based on implementation specific
  31. * restrictions on the url. That case is considered a not found - returning
  32. * an empty array. Exceptions are only used to abort the whole request in
  33. * case something is seriously broken, like the storage backend being down.
  34. *
  35. * Note that implementations may not implement an optimal matching
  36. * algorithm, simply a reasonable first pass. That allows for potentially
  37. * very large route sets to be filtered down to likely candidates, which
  38. * may then be filtered in memory more completely.
  39. *
  40. * @param Request $request A request against which to match.
  41. *
  42. * @return RouteCollection with all Routes that could potentially match
  43. * $request. Empty collection if nothing can match.
  44. */
  45. public function getRouteCollectionForRequest(Request $request);
  46. /**
  47. * Find the route using the provided route name.
  48. *
  49. * @param string $name The route name to fetch.
  50. *
  51. * @return Route
  52. *
  53. * @throws RouteNotFoundException If there is no route with that name in
  54. * this repository
  55. */
  56. public function getRouteByName($name);
  57. /**
  58. * Find many routes by their names using the provided list of names.
  59. *
  60. * Note that this method may not throw an exception if some of the routes
  61. * are not found or are not actually Route instances. It will just return the
  62. * list of those Route instances it found.
  63. *
  64. * This method exists in order to allow performance optimizations. The
  65. * simple implementation could be to just repeatedly call
  66. * $this->getRouteByName() while catching and ignoring eventual exceptions.
  67. *
  68. * If $names is null, this method SHOULD return a collection of all routes
  69. * known to this provider. If there are many routes to be expected, usage of
  70. * a lazy loading collection is recommended. A provider MAY only return a
  71. * subset of routes to e.g. support paging or other concepts, but be aware
  72. * that the DynamicRouter will only call this method once per
  73. * DynamicRouter::getRouteCollection() call.
  74. *
  75. * @param array|null $names The list of names to retrieve, In case of null,
  76. * the provider will determine what routes to return.
  77. *
  78. * @return Route[] Iterable list with the keys being the names from the
  79. * $names array.
  80. */
  81. public function getRoutesByNames($names);
  82. }