IURLGenerator.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Bart Visscher <bartv@thisnet.nl>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. namespace OCP;
  29. /**
  30. * Class to generate URLs
  31. * @since 6.0.0
  32. */
  33. interface IURLGenerator {
  34. /**
  35. * Returns the URL for a route
  36. * @param string $routeName the name of the route
  37. * @param array $arguments an array with arguments which will be filled into the url
  38. * @return string the url
  39. * @since 6.0.0
  40. */
  41. public function linkToRoute(string $routeName, array $arguments = array()): string;
  42. /**
  43. * Returns the absolute URL for a route
  44. * @param string $routeName the name of the route
  45. * @param array $arguments an array with arguments which will be filled into the url
  46. * @return string the absolute url
  47. * @since 8.0.0
  48. */
  49. public function linkToRouteAbsolute(string $routeName, array $arguments = array()): string;
  50. /**
  51. * @param string $routeName
  52. * @param array $arguments
  53. * @return string
  54. * @since 15.0.0
  55. */
  56. public function linkToOCSRouteAbsolute(string $routeName, array $arguments = []): string;
  57. /**
  58. * Returns an URL for an image or file
  59. * @param string $appName the name of the app
  60. * @param string $file the name of the file
  61. * @param array $args array with param=>value, will be appended to the returned url
  62. * The value of $args will be urlencoded
  63. * @return string the url
  64. * @since 6.0.0
  65. */
  66. public function linkTo(string $appName, string $file, array $args = array()): string;
  67. /**
  68. * Returns the link to an image, like linkTo but only with prepending img/
  69. * @param string $appName the name of the app
  70. * @param string $file the name of the file
  71. * @return string the url
  72. * @since 6.0.0
  73. */
  74. public function imagePath(string $appName, string $file): string;
  75. /**
  76. * Makes an URL absolute
  77. * @param string $url the url in the ownCloud host
  78. * @return string the absolute version of the url
  79. * @since 6.0.0
  80. */
  81. public function getAbsoluteURL(string $url): string;
  82. /**
  83. * @param string $key
  84. * @return string url to the online documentation
  85. * @since 8.0.0
  86. */
  87. public function linkToDocs(string $key): string;
  88. /**
  89. * @return string base url of the current request
  90. * @since 13.0.0
  91. */
  92. public function getBaseUrl(): string;
  93. }