UrlGeneratorInterface.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\AdminBundle\Admin;
  11. use Sonata\AdminBundle\Route\RouteGeneratorInterface;
  12. /**
  13. * Contains url generation logic related to an admin.
  14. *
  15. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  16. */
  17. interface UrlGeneratorInterface
  18. {
  19. /**
  20. * Returns the list of available urls.
  21. *
  22. * @return RouteCollection the list of available urls
  23. */
  24. public function getRoutes();
  25. /**
  26. * Return the parameter name used to represent the id in the url.
  27. *
  28. * @return string
  29. */
  30. public function getRouterIdParameter();
  31. /**
  32. * @param RouteGeneratorInterface $routeGenerator
  33. */
  34. public function setRouteGenerator(RouteGeneratorInterface $routeGenerator);
  35. /**
  36. * Generates the object url with the given $name.
  37. *
  38. * @param string $name
  39. * @param mixed $object
  40. * @param array $parameters
  41. * @param bool $absolute
  42. *
  43. * @return string return a complete url
  44. */
  45. public function generateObjectUrl($name, $object, array $parameters = array(), $absolute = false);
  46. /**
  47. * Generates a url for the given parameters.
  48. *
  49. * @param string $name
  50. * @param array $parameters
  51. * @param bool $absolute
  52. *
  53. * @return string return a complete url
  54. */
  55. public function generateUrl($name, array $parameters = array(), $absolute = false);
  56. /**
  57. * Generates a url for the given parameters.
  58. *
  59. * @param string $name
  60. * @param array $parameters
  61. * @param bool $absolute
  62. *
  63. * @return array return url parts: 'route', 'routeParameters', 'routeAbsolute'
  64. */
  65. public function generateMenuUrl($name, array $parameters = array(), $absolute = false);
  66. /**
  67. * @param mixed $entity
  68. *
  69. * @return string a string representation of the id that is safe to use in a url
  70. */
  71. public function getUrlsafeIdentifier($entity);
  72. }