From e42f262d85ddd891ce823dd5d9b5a4a87c8a7786 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 18 Dec 2015 11:46:21 +0100 Subject: properly use OCP\Util instead of OC_Helper --- lib/public/util.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/public') diff --git a/lib/public/util.php b/lib/public/util.php index da4aa6e9deb..6f5016fa4a1 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -269,7 +269,10 @@ class Util { * @since 4.0.0 - parameter $args was added in 4.5.0 */ public static function linkToAbsolute( $app, $file, $args = array() ) { - return(\OC_Helper::linkToAbsolute( $app, $file, $args )); + $urlGenerator = \OC::$server->getURLGenerator(); + return $urlGenerator->getAbsoluteURL( + $urlGenerator->linkTo($app, $file, $args) + ); } /** -- cgit v1.2.3 From 450e2f3bd308388e5df01b2b2ea38e6bf16b1c67 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 18 Dec 2015 12:00:18 +0100 Subject: Move OC_Helper code to OCP\Util for linkToRemote --- lib/private/helper.php | 26 -------------------------- lib/public/util.php | 6 +++++- tests/lib/helper.php | 32 -------------------------------- 3 files changed, 5 insertions(+), 59 deletions(-) (limited to 'lib/public') diff --git a/lib/private/helper.php b/lib/private/helper.php index efbc6bda1db..bd69c13de50 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -53,32 +53,6 @@ use Symfony\Component\Process\ExecutableFinder; class OC_Helper { private static $templateManager; - /** - * Creates an url for remote use - * @param string $service id - * @return string the url - * - * Returns a url to the given service. - */ - public static function linkToRemoteBase($service) { - return OC::$server->getURLGenerator()->linkTo('', 'remote.php') . '/' . $service; - } - - /** - * Creates an absolute url for remote use - * @param string $service id - * @param bool $add_slash - * @return string the url - * - * Returns a absolute url to the given service. - */ - public static function linkToRemote($service, $add_slash = true) { - return OC::$server->getURLGenerator()->getAbsoluteURL( - self::linkToRemoteBase($service) - . (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : '') - ); - } - /** * Creates an absolute url for public use * @param string $service id diff --git a/lib/public/util.php b/lib/public/util.php index 6f5016fa4a1..a9fe0e47de6 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -282,7 +282,11 @@ class Util { * @since 4.0.0 */ public static function linkToRemote( $service ) { - return(\OC_Helper::linkToRemote( $service )); + $urlGenerator = \OC::$server->getURLGenerator(); + $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; + return $urlGenerator->getAbsoluteURL( + $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') + ); } /** diff --git a/tests/lib/helper.php b/tests/lib/helper.php index 22737f170d8..468d32bc37a 100644 --- a/tests/lib/helper.php +++ b/tests/lib/helper.php @@ -243,38 +243,6 @@ class Test_Helper extends \Test\TestCase { // Url generator methods - /** - * @small - * test linkToRemoteBase URL construction - */ - public function testLinkToRemoteBase() { - \OC::$WEBROOT = ''; - $result = \OC_Helper::linkToRemoteBase('webdav'); - $this->assertEquals('/remote.php/webdav', $result); - - \OC::$WEBROOT = '/owncloud'; - $result = \OC_Helper::linkToRemoteBase('webdav'); - $this->assertEquals('/owncloud/remote.php/webdav', $result); - } - - /** - * @small - * test linkToRemote URL construction - */ - public function testLinkToRemote() { - \OC::$WEBROOT = ''; - $result = \OC_Helper::linkToRemote('webdav'); - $this->assertEquals('http://localhost/remote.php/webdav/', $result); - $result = \OC_Helper::linkToRemote('webdav', false); - $this->assertEquals('http://localhost/remote.php/webdav', $result); - - \OC::$WEBROOT = '/owncloud'; - $result = \OC_Helper::linkToRemote('webdav'); - $this->assertEquals('http://localhost/owncloud/remote.php/webdav/', $result); - $result = \OC_Helper::linkToRemote('webdav', false); - $this->assertEquals('http://localhost/owncloud/remote.php/webdav', $result); - } - /** * @small * test linkToPublic URL construction -- cgit v1.2.3