IURLGenerator.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. * @param string $routeName
  51. * @param array $arguments
  52. * @return string
  53. * @since 15.0.0
  54. */
  55. public function linkToOCSRouteAbsolute(string $routeName, array $arguments = []): string;
  56. /**
  57. * Returns an URL for an image or file
  58. * @param string $appName the name of the app
  59. * @param string $file the name of the file
  60. * @param array $args array with param=>value, will be appended to the returned url
  61. * The value of $args will be urlencoded
  62. * @return string the url
  63. * @since 6.0.0
  64. */
  65. public function linkTo(string $appName, string $file, array $args = array()): string;
  66. /**
  67. * Returns the link to an image, like linkTo but only with prepending img/
  68. * @param string $appName the name of the app
  69. * @param string $file the name of the file
  70. * @return string the url
  71. * @since 6.0.0
  72. */
  73. public function imagePath(string $appName, string $file): string;
  74. /**
  75. * Makes an URL absolute
  76. * @param string $url the url in the ownCloud host
  77. * @return string the absolute version of the url
  78. * @since 6.0.0
  79. */
  80. public function getAbsoluteURL(string $url): string;
  81. /**
  82. * @param string $key
  83. * @return string url to the online documentation
  84. * @since 8.0.0
  85. */
  86. public function linkToDocs(string $key): string;
  87. /**
  88. * @return string base url of the current request
  89. * @since 13.0.0
  90. */
  91. public function getBaseUrl(): string;
  92. }