IURLGenerator.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCP;
  28. /**
  29. * Class to generate URLs
  30. * @since 6.0.0
  31. */
  32. interface IURLGenerator {
  33. /**
  34. * Returns the URL for a route
  35. * @param string $routeName the name of the route
  36. * @param array $arguments an array with arguments which will be filled into the url
  37. * @return string the url
  38. * @since 6.0.0
  39. */
  40. public function linkToRoute(string $routeName, array $arguments = array()): string;
  41. /**
  42. * Returns the absolute URL for a route
  43. * @param string $routeName the name of the route
  44. * @param array $arguments an array with arguments which will be filled into the url
  45. * @return string the absolute url
  46. * @since 8.0.0
  47. */
  48. public function linkToRouteAbsolute(string $routeName, array $arguments = array()): string;
  49. /**
  50. * Returns an URL for an image or file
  51. * @param string $appName the name of the app
  52. * @param string $file the name of the file
  53. * @param array $args array with param=>value, will be appended to the returned url
  54. * The value of $args will be urlencoded
  55. * @return string the url
  56. * @since 6.0.0
  57. */
  58. public function linkTo(string $appName, string $file, array $args = array()): string;
  59. /**
  60. * Returns the link to an image, like linkTo but only with prepending img/
  61. * @param string $appName the name of the app
  62. * @param string $file the name of the file
  63. * @return string the url
  64. * @since 6.0.0
  65. */
  66. public function imagePath(string $appName, string $file): string;
  67. /**
  68. * Makes an URL absolute
  69. * @param string $url the url in the ownCloud host
  70. * @return string the absolute version of the url
  71. * @since 6.0.0
  72. */
  73. public function getAbsoluteURL(string $url): string;
  74. /**
  75. * @param string $key
  76. * @return string url to the online documentation
  77. * @since 8.0.0
  78. */
  79. public function linkToDocs(string $key): string;
  80. /**
  81. * @return string base url of the current request
  82. * @since 13.0.0
  83. */
  84. public function getBaseUrl(): string;
  85. }