summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2017-06-15 21:51:51 +0200
committerJulius Härtl <jus@bitgrid.net>2017-06-16 10:51:31 +0200
commitf039ba748032a78e70845adad9152730715a8219 (patch)
tree908786d51bdf65f90b906fd9289bd4fbc3f475f0 /lib/private
parent0999ed1778d7b1d95e4fb45b5d28162f2cc4d985 (diff)
downloadnextcloud-server-f039ba748032a78e70845adad9152730715a8219.tar.gz
nextcloud-server-f039ba748032a78e70845adad9152730715a8219.zip
Add tests and inject IRequest
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Server.php8
-rw-r--r--lib/private/URLGenerator.php12
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 159fab20be4..489683aa127 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -414,9 +414,11 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
$config = $c->getConfig();
$cacheFactory = $c->getMemCacheFactory();
+ $request = $c->getRequest();
return new \OC\URLGenerator(
$config,
- $cacheFactory
+ $cacheFactory,
+ $request
);
});
$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
@@ -433,13 +435,15 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerAlias('UserCache', \OCP\ICache::class);
$this->registerService(Factory::class, function (Server $c) {
+
$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
'\\OC\\Memcache\\ArrayCache',
'\\OC\\Memcache\\ArrayCache',
'\\OC\\Memcache\\ArrayCache'
);
$config = $c->getConfig();
- $urlGenerator = new URLGenerator($config, $arrayCacheFactory);
+ $request = $c->getRequest();
+ $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request);
if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
$v = \OC_App::getAppVersions();
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index 6db675e7d77..073d40b0de8 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -35,7 +35,9 @@ namespace OC;
use OCP\ICacheFactory;
use OCP\IConfig;
+use OCP\IRequest;
use OCP\IURLGenerator;
+use OCP\Route\IRoute;
use RuntimeException;
/**
@@ -46,15 +48,20 @@ class URLGenerator implements IURLGenerator {
private $config;
/** @var ICacheFactory */
private $cacheFactory;
+ /** @var IRequest */
+ private $request;
/**
* @param IConfig $config
* @param ICacheFactory $cacheFactory
+ * @param IRequest $request
*/
public function __construct(IConfig $config,
- ICacheFactory $cacheFactory) {
+ ICacheFactory $cacheFactory,
+ IRequest $request) {
$this->config = $config;
$this->cacheFactory = $cacheFactory;
+ $this->request = $request;
}
/**
@@ -244,7 +251,6 @@ class URLGenerator implements IURLGenerator {
* @return string base url of the current request
*/
public function getBaseUrl() {
- $request = \OC::$server->getRequest();
- return $request->getServerProtocol() . '://' . $request->getServerHost() . \OC::$WEBROOT;
+ return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT;
}
}