UrlInterface.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. interface UrlInterface
  12. {
  13. /**#@+
  14. * Possible URL types
  15. */
  16. const URL_TYPE_LINK = 'link';
  17. const URL_TYPE_DIRECT_LINK = 'direct_link';
  18. const URL_TYPE_WEB = 'web';
  19. const URL_TYPE_MEDIA = 'media';
  20. const URL_TYPE_STATIC = 'static';
  21. const URL_TYPE_JS = 'js';
  22. /**#@-*/
  23. /**
  24. * Default url type
  25. *
  26. * Equals to self::URL_TYPE_LINK
  27. */
  28. const DEFAULT_URL_TYPE = 'link';
  29. /**
  30. * Default controller name
  31. */
  32. const DEFAULT_CONTROLLER_NAME = 'index';
  33. /**
  34. * Default action name
  35. */
  36. const DEFAULT_ACTION_NAME = 'index';
  37. /**
  38. * Rewrite request path alias
  39. */
  40. const REWRITE_REQUEST_PATH_ALIAS = 'rewrite_request_path';
  41. /**
  42. * Session namespace to refer in other places
  43. */
  44. const SESSION_NAMESPACE = 'frontend';
  45. /**
  46. * Retrieve use session rule
  47. *
  48. * @return bool
  49. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  50. */
  51. public function getUseSession();
  52. /**
  53. * Retrieve Base URL
  54. *
  55. * @param array $params
  56. * @return string
  57. */
  58. public function getBaseUrl($params = []);
  59. /**
  60. * Retrieve current url with port number (if not default used)
  61. *
  62. * @return string
  63. */
  64. public function getCurrentUrl();
  65. /**
  66. * Retrieve route URL
  67. *
  68. * @param string $routePath
  69. * @param array $routeParams
  70. * @return string
  71. */
  72. public function getRouteUrl($routePath = null, $routeParams = null);
  73. /**
  74. * Add session param
  75. *
  76. * @return \Magento\Framework\UrlInterface
  77. */
  78. public function addSessionParam();
  79. /**
  80. * Add query parameters
  81. *
  82. * @param array $data
  83. * @return \Magento\Framework\UrlInterface
  84. */
  85. public function addQueryParams(array $data);
  86. /**
  87. * Set query param
  88. *
  89. * @param string $key
  90. * @param mixed $data
  91. * @return \Magento\Framework\UrlInterface
  92. */
  93. public function setQueryParam($key, $data);
  94. /**
  95. * Build url by requested path and parameters
  96. *
  97. * @param string|null $routePath
  98. * @param array|null $routeParams
  99. * @return string
  100. */
  101. public function getUrl($routePath = null, $routeParams = null);
  102. /**
  103. * Escape (enclosure) URL string
  104. *
  105. * @param string $value
  106. * @return string
  107. */
  108. public function escape($value);
  109. /**
  110. * Build url by direct url and parameters
  111. *
  112. * @param string $url
  113. * @param array $params
  114. * @return string
  115. */
  116. public function getDirectUrl($url, $params = []);
  117. /**
  118. * Replace Session ID value in URL
  119. *
  120. * @param string $html
  121. * @return string
  122. */
  123. public function sessionUrlVar($html);
  124. /**
  125. * Check if users originated URL is one of the domain URLs assigned to stores
  126. *
  127. * @return boolean
  128. */
  129. public function isOwnOriginUrl();
  130. /**
  131. * Return frontend redirect URL with SID and other session parameters if any
  132. *
  133. * @param string $url
  134. *
  135. * @return string
  136. */
  137. public function getRedirectUrl($url);
  138. /**
  139. * Set scope entity
  140. *
  141. * @param mixed $params
  142. * @return \Magento\Framework\UrlInterface
  143. */
  144. public function setScope($params);
  145. }