summaryrefslogtreecommitdiffstats
path: root/lib/private/URLGenerator.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/URLGenerator.php')
-rw-r--r--lib/private/URLGenerator.php17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index e90d8cf1d1c..4da6a91b6c9 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -44,6 +44,7 @@ use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IURLGenerator;
+use OCP\Route\IRouter;
use RuntimeException;
/**
@@ -56,18 +57,17 @@ class URLGenerator implements IURLGenerator {
private $cacheFactory;
/** @var IRequest */
private $request;
+ /** @var IRouter*/
+ private $router;
- /**
- * @param IConfig $config
- * @param ICacheFactory $cacheFactory
- * @param IRequest $request
- */
public function __construct(IConfig $config,
ICacheFactory $cacheFactory,
- IRequest $request) {
+ IRequest $request,
+ IRouter $router) {
$this->config = $config;
$this->cacheFactory = $cacheFactory;
$this->request = $request;
+ $this->router = $router;
}
/**
@@ -80,8 +80,7 @@ class URLGenerator implements IURLGenerator {
* Returns a url to the given route.
*/
public function linkToRoute(string $routeName, array $arguments = []): string {
- // TODO: mock router
- return \OC::$server->getRouter()->generate($routeName, $arguments);
+ return $this->router->generate($routeName, $arguments);
}
/**
@@ -97,7 +96,7 @@ class URLGenerator implements IURLGenerator {
}
public function linkToOCSRouteAbsolute(string $routeName, array $arguments = []): string {
- $route = \OC::$server->getRouter()->generate('ocs.'.$routeName, $arguments, false);
+ $route = $this->router->generate('ocs.'.$routeName, $arguments, false);
$indexPhpPos = strpos($route, '/index.php/');
if ($indexPhpPos !== false) {