RouteObjectInterface.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /**
  12. * Classes for entries in the routing table may implement this interface in
  13. * addition to extending Symfony\Component\Routing\Route.
  14. *
  15. * If they do, the DynamicRouter will request the route content and put it into
  16. * the RouteObjectInterface::CONTENT_OBJECT field. The DynamicRouter will also
  17. * request getRouteKey and this will be used instead of the symfony core compatible
  18. * route name and can contain any characters.
  19. *
  20. * Some fields in defaults have a special meaning in the getDefaults(). In addition
  21. * to the constants defined in this class, _locale and _controller are also used.
  22. */
  23. interface RouteObjectInterface
  24. {
  25. /**
  26. * Field name that will hold the route name that was matched.
  27. */
  28. const ROUTE_NAME = '_route';
  29. /**
  30. * Field name of the route object that was matched.
  31. */
  32. const ROUTE_OBJECT = '_route_object';
  33. /**
  34. * Field name for an explicit controller name to be used with this route.
  35. */
  36. const CONTROLLER_NAME = '_controller';
  37. /**
  38. * Field name for an explicit template to be used with this route.
  39. * i.e. CmfContentBundle:StaticContent:index.html.twig.
  40. */
  41. const TEMPLATE_NAME = '_template';
  42. /**
  43. * Field name for the content of the current route, if any.
  44. */
  45. const CONTENT_OBJECT = '_content';
  46. /**
  47. * Field name for the content id of the current route, if any.
  48. */
  49. const CONTENT_ID = '_content_id';
  50. /**
  51. * Get the content document this route entry stands for. If non-null,
  52. * the ControllerClassMapper uses it to identify a controller and
  53. * the content is passed to the controller.
  54. *
  55. * If there is no specific content for this url (i.e. its an "application"
  56. * page), may return null.
  57. *
  58. * @return object the document or entity this route entry points to
  59. */
  60. public function getContent();
  61. /**
  62. * Get the route name.
  63. *
  64. * Normal symfony routes do not know their name, the name is only known
  65. * from the route collection. In the CMF, it is possible to use route
  66. * documents outside of collections, and thus useful to have routes provide
  67. * their name.
  68. *
  69. * There are no limitations to allowed characters in the name.
  70. *
  71. * @return string|null the route name or null to use the default name
  72. * (e.g. from route collection if known)
  73. */
  74. public function getRouteKey();
  75. }