Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-10-08 19:29:52 +0300
committerMorris Jobke <hey@morrisjobke.de>2018-10-08 19:29:52 +0300
commitdb345e4c6dccd690b9cc5f53642696ab73290daf (patch)
treeb31618fbe87ac57e7e8495939042ddae4a5cbd01
parent2a9e00635531a9b4269c9dc8fc97eeca1e6ce8cf (diff)
Deprecate unused, private OC_Helper::linkToPublic
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r--lib/private/legacy/helper.php17
-rw-r--r--lib/public/Util.php7
-rw-r--r--tests/lib/LegacyHelperTest.php38
3 files changed, 6 insertions, 56 deletions
diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php
index 5a05e147c2b..d9aa22e2935 100644
--- a/lib/private/legacy/helper.php
+++ b/lib/private/legacy/helper.php
@@ -52,23 +52,6 @@ class OC_Helper {
private static $templateManager;
/**
- * Creates an absolute url for public use
- * @param string $service id
- * @param bool $add_slash
- * @return string the url
- *
- * Returns a absolute url to the given service.
- */
- public static function linkToPublic($service, $add_slash = false) {
- if ($service === 'files') {
- $url = OC::$server->getURLGenerator()->getAbsoluteURL('/s');
- } else {
- $url = OC::$server->getURLGenerator()->getAbsoluteURL(OC::$server->getURLGenerator()->linkTo('', 'public.php').'?service='.$service);
- }
- return $url . (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : '');
- }
-
- /**
* Make a human file size
* @param int $bytes file size in bytes
* @return string a human readable file size
diff --git a/lib/public/Util.php b/lib/public/Util.php
index 3a1c28a899a..fb2d31f3dce 100644
--- a/lib/public/Util.php
+++ b/lib/public/Util.php
@@ -230,9 +230,14 @@ class Util {
* @param string $service id
* @return string the url
* @since 4.5.0
+ * @deprecated 15.0.0 - use OCP\IURLGenerator
*/
public static function linkToPublic($service) {
- return \OC_Helper::linkToPublic($service);
+ $urlGenerator = \OC::$server->getURLGenerator();
+ if ($service === 'files') {
+ return $urlGenerator->getAbsoluteURL('/s');
+ }
+ return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
}
/**
diff --git a/tests/lib/LegacyHelperTest.php b/tests/lib/LegacyHelperTest.php
index 736c5bf7fad..76f38706b4c 100644
--- a/tests/lib/LegacyHelperTest.php
+++ b/tests/lib/LegacyHelperTest.php
@@ -222,44 +222,6 @@ class LegacyHelperTest extends \Test\TestCase {
);
}
- // Url generator methods
-
- /**
- * @small
- * test linkToPublic URL construction
- */
- public function testLinkToPublic() {
- \OC::$WEBROOT = '';
- $result = \OC_Helper::linkToPublic('files');
- $this->assertEquals('http://localhost/s', $result);
- $result = \OC_Helper::linkToPublic('files', false);
- $this->assertEquals('http://localhost/s', $result);
- $result = \OC_Helper::linkToPublic('files', true);
- $this->assertEquals('http://localhost/s/', $result);
-
- $result = \OC_Helper::linkToPublic('other');
- $this->assertEquals('http://localhost/public.php?service=other', $result);
- $result = \OC_Helper::linkToPublic('other', false);
- $this->assertEquals('http://localhost/public.php?service=other', $result);
- $result = \OC_Helper::linkToPublic('other', true);
- $this->assertEquals('http://localhost/public.php?service=other/', $result);
-
- \OC::$WEBROOT = '/owncloud';
- $result = \OC_Helper::linkToPublic('files');
- $this->assertEquals('http://localhost/owncloud/s', $result);
- $result = \OC_Helper::linkToPublic('files', false);
- $this->assertEquals('http://localhost/owncloud/s', $result);
- $result = \OC_Helper::linkToPublic('files', true);
- $this->assertEquals('http://localhost/owncloud/s/', $result);
-
- $result = \OC_Helper::linkToPublic('other');
- $this->assertEquals('http://localhost/owncloud/public.php?service=other', $result);
- $result = \OC_Helper::linkToPublic('other', false);
- $this->assertEquals('http://localhost/owncloud/public.php?service=other', $result);
- $result = \OC_Helper::linkToPublic('other', true);
- $this->assertEquals('http://localhost/owncloud/public.php?service=other/', $result);
- }
-
/**
* Tests recursive folder deletion with rmdirr()
*/