UrlGenerator.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace Illuminate\Contracts\Routing;
  3. interface UrlGenerator
  4. {
  5. /**
  6. * Get the current URL for the request.
  7. *
  8. * @return string
  9. */
  10. public function current();
  11. /**
  12. * Get the URL for the previous request.
  13. *
  14. * @param mixed $fallback
  15. * @return string
  16. */
  17. public function previous($fallback = false);
  18. /**
  19. * Generate an absolute URL to the given path.
  20. *
  21. * @param string $path
  22. * @param mixed $extra
  23. * @param bool|null $secure
  24. * @return string
  25. */
  26. public function to($path, $extra = [], $secure = null);
  27. /**
  28. * Generate a secure, absolute URL to the given path.
  29. *
  30. * @param string $path
  31. * @param array $parameters
  32. * @return string
  33. */
  34. public function secure($path, $parameters = []);
  35. /**
  36. * Generate the URL to an application asset.
  37. *
  38. * @param string $path
  39. * @param bool|null $secure
  40. * @return string
  41. */
  42. public function asset($path, $secure = null);
  43. /**
  44. * Get the URL to a named route.
  45. *
  46. * @param string $name
  47. * @param mixed $parameters
  48. * @param bool $absolute
  49. * @return string
  50. *
  51. * @throws \InvalidArgumentException
  52. */
  53. public function route($name, $parameters = [], $absolute = true);
  54. /**
  55. * Create a signed route URL for a named route.
  56. *
  57. * @param string $name
  58. * @param mixed $parameters
  59. * @param \DateTimeInterface|\DateInterval|int|null $expiration
  60. * @param bool $absolute
  61. * @return string
  62. *
  63. * @throws \InvalidArgumentException
  64. */
  65. public function signedRoute($name, $parameters = [], $expiration = null, $absolute = true);
  66. /**
  67. * Create a temporary signed route URL for a named route.
  68. *
  69. * @param string $name
  70. * @param \DateTimeInterface|\DateInterval|int $expiration
  71. * @param array $parameters
  72. * @param bool $absolute
  73. * @return string
  74. */
  75. public function temporarySignedRoute($name, $expiration, $parameters = [], $absolute = true);
  76. /**
  77. * Generate an absolute URL with the given query parameters.
  78. *
  79. * @param string $path
  80. * @param array $query
  81. * @param mixed $extra
  82. * @param bool|null $secure
  83. * @return string
  84. */
  85. public function query($path, $query = [], $extra = [], $secure = null);
  86. /**
  87. * Get the URL to a controller action.
  88. *
  89. * @param string|array $action
  90. * @param mixed $parameters
  91. * @param bool $absolute
  92. * @return string
  93. */
  94. public function action($action, $parameters = [], $absolute = true);
  95. /**
  96. * Get the root controller namespace.
  97. *
  98. * @return string
  99. */
  100. public function getRootControllerNamespace();
  101. /**
  102. * Set the root controller namespace.
  103. *
  104. * @param string $rootNamespace
  105. * @return $this
  106. */
  107. public function setRootControllerNamespace($rootNamespace);
  108. }