diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-11-02 23:16:51 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-11-02 23:16:51 +0100 |
commit | 68cebef64ca38ea93bc1006d667726f42d7f9805 (patch) | |
tree | e0f060c68fb0d85d303eabb263cd8666407bb072 /lib | |
parent | 8653d1486243079426a855584111db519af6e544 (diff) | |
download | nextcloud-server-68cebef64ca38ea93bc1006d667726f42d7f9805.tar.gz nextcloud-server-68cebef64ca38ea93bc1006d667726f42d7f9805.zip |
DI for root.php
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Node/Root.php | 54 | ||||
-rw-r--r-- | lib/private/Server.php | 9 |
2 files changed, 41 insertions, 22 deletions
diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 8434ed64008..515a795d6e0 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -36,6 +36,8 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OC\Hooks\PublicEmitter; use OCP\Files\IRootFolder; +use OCP\ILogger; +use OCP\IUserManager; /** * Class Root @@ -57,42 +59,43 @@ use OCP\Files\IRootFolder; * @package OC\Files\Node */ class Root extends Folder implements IRootFolder { - - /** - * @var \OC\Files\Mount\Manager $mountManager - */ + /** @var Manager */ private $mountManager; - - /** - * @var \OC\Hooks\PublicEmitter - */ + /** @var PublicEmitter */ private $emitter; - - /** - * @var \OC\User\User $user - */ + /** @var null|\OC\User\User */ private $user; - + /** @var CappedMemoryCache */ private $userFolderCache; - - /** - * @var IUserMountCache - */ + /** @var IUserMountCache */ private $userMountCache; + /** @var ILogger */ + private $logger; + /** @var IUserManager */ + private $userManager; /** * @param \OC\Files\Mount\Manager $manager * @param \OC\Files\View $view * @param \OC\User\User|null $user * @param IUserMountCache $userMountCache - */ - public function __construct($manager, $view, $user, IUserMountCache $userMountCache) { + * @param ILogger $logger + * @param IUserManager $userManager + */ + public function __construct($manager, + $view, + $user, + IUserMountCache $userMountCache, + ILogger $logger, + IUserManager $userManager) { parent::__construct($this, $view, ''); $this->mountManager = $manager; $this->user = $user; $this->emitter = new PublicEmitter(); $this->userFolderCache = new CappedMemoryCache(); $this->userMountCache = $userMountCache; + $this->logger = $logger; + $this->userManager = $userManager; } /** @@ -345,12 +348,21 @@ class Root extends Folder implements IRootFolder { * * @param String $userId user ID * @return \OCP\Files\Folder + * @throws \OC\User\NoUserException */ public function getUserFolder($userId) { - $userObject = \OC::$server->getUserManager()->get($userId); + $userObject = $this->userManager->get($userId); if (is_null($userObject)) { - \OCP\Util::writeLog('files', 'Backends provided no user object for ' . $userId, \OCP\Util::ERROR); + $this->logger->error( + sprintf( + 'Backends provided no user object for %s', + $userId + ), + [ + 'app' => 'files', + ] + ); throw new \OC\User\NoUserException('Backends provided no user object'); } diff --git a/lib/private/Server.php b/lib/private/Server.php index dca50c15733..9f993ade7fe 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -182,7 +182,14 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService('RootFolder', function (Server $c) { $manager = \OC\Files\Filesystem::getMountManager(null); $view = new View(); - $root = new Root($manager, $view, null, $c->getUserMountCache()); + $root = new Root( + $manager, + $view, + null, + $c->getUserMountCache(), + $this->getLogger(), + $this->getUserManager() + ); $connector = new HookConnector($root, $view); $connector->viewToNode(); return $root; |