RouteMatchInterface.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace Drupal\Core\Routing;
  3. /**
  4. * Provides an interface for classes representing the result of routing.
  5. *
  6. * Routing is the process of selecting the best matching candidate from a
  7. * collection of routes for an incoming request. The relevant properties of a
  8. * request include the path as well as a list of raw parameter values derived
  9. * from the URL. If an appropriate route is found, raw parameter values will be
  10. * upcast automatically if possible.
  11. *
  12. * The route match object contains useful information about the selected route
  13. * as well as the raw and upcast parameters derived from the incoming
  14. * request.
  15. *
  16. * @ingroup routing
  17. */
  18. interface RouteMatchInterface {
  19. /**
  20. * Returns the route name.
  21. *
  22. * @return string|null
  23. * The route name. NULL if no route is matched.
  24. */
  25. public function getRouteName();
  26. /**
  27. * Returns the route object.
  28. *
  29. * @return \Symfony\Component\Routing\Route|null
  30. * The route object. NULL if no route is matched.
  31. */
  32. public function getRouteObject();
  33. /**
  34. * Returns the processed value of a named route parameter.
  35. *
  36. * Raw URL parameters are processed by the parameter conversion system, which
  37. * does operations such as converting entity ID parameters to fully-loaded
  38. * entities. For example, the path node/12345 would have a raw node ID
  39. * parameter value of 12345, while the processed parameter value would be the
  40. * corresponding loaded node object.
  41. *
  42. * @param string $parameter_name
  43. * The parameter name.
  44. *
  45. * @return mixed|null
  46. * The parameter value. NULL if the route doesn't define the parameter or
  47. * if the parameter value can't be determined from the request.
  48. *
  49. * @see \Drupal\Core\Routing\RouteMatchInterface::getRawParameter()
  50. */
  51. public function getParameter($parameter_name);
  52. /**
  53. * Returns the bag of all processed route parameters.
  54. *
  55. * Raw URL parameters are processed by the parameter conversion system, which
  56. * does operations such as converting entity ID parameters to fully-loaded
  57. * entities. For example, the path node/12345 would have a raw node ID
  58. * parameter value of 12345, while the processed parameter value would be the
  59. * corresponding loaded node object.
  60. *
  61. * @return \Symfony\Component\HttpFoundation\ParameterBag
  62. * The parameter bag.
  63. *
  64. * @see \Drupal\Core\Routing\RouteMatchInterface::getRawParameters()
  65. */
  66. public function getParameters();
  67. /**
  68. * Returns the raw value of a named route parameter.
  69. *
  70. * @param string $parameter_name
  71. * The parameter name.
  72. *
  73. * @return string|null
  74. * The raw (non-upcast) parameter value. NULL if the route doesn't define
  75. * the parameter or if the raw parameter value can't be determined from the
  76. * request.
  77. *
  78. * @see \Drupal\Core\Routing\RouteMatchInterface::getParameter()
  79. */
  80. public function getRawParameter($parameter_name);
  81. /**
  82. * Returns the bag of all raw route parameters.
  83. *
  84. * @return \Symfony\Component\HttpFoundation\ParameterBag
  85. * The parameter bag.
  86. *
  87. * @see \Drupal\Core\Routing\RouteMatchInterface::getParameters()
  88. */
  89. public function getRawParameters();
  90. }