From 48ea7251d74302993bbd1a86d7c01b45417c1965 Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma <roeland@famdouma.nl>
Date: Sat, 13 Jan 2018 20:36:02 +0100
Subject: [PATCH] Use \OC\User\Manager internally in the avatarmanager

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
---
 lib/private/AvatarManager.php   | 8 ++++----
 lib/private/Server.php          | 7 ++++---
 tests/lib/AvatarManagerTest.php | 5 +++--
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/lib/private/AvatarManager.php b/lib/private/AvatarManager.php
index dea7f5f3a07..eb455642101 100644
--- a/lib/private/AvatarManager.php
+++ b/lib/private/AvatarManager.php
@@ -28,13 +28,13 @@ declare(strict_types=1);
 
 namespace OC;
 
+use OC\User\Manager;
 use OCP\Files\IAppData;
 use OCP\Files\NotFoundException;
 use OCP\IAvatar;
 use OCP\IAvatarManager;
 use OCP\IConfig;
 use OCP\ILogger;
-use OCP\IUserManager;
 use OCP\IL10N;
 
 /**
@@ -42,7 +42,7 @@ use OCP\IL10N;
  */
 class AvatarManager implements IAvatarManager {
 
-	/** @var  IUserManager */
+	/** @var Manager */
 	private $userManager;
 
 	/** @var IAppData */
@@ -60,14 +60,14 @@ class AvatarManager implements IAvatarManager {
 	/**
 	 * AvatarManager constructor.
 	 *
-	 * @param IUserManager $userManager
+	 * @param Manager $userManager
 	 * @param IAppData $appData
 	 * @param IL10N $l
 	 * @param ILogger $logger
 	 * @param IConfig $config
 	 */
 	public function __construct(
-			IUserManager $userManager,
+			Manager $userManager,
 			IAppData $appData,
 			IL10N $l,
 			ILogger $logger,
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 4a851d67226..380ab633b8c 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -284,11 +284,12 @@ class Server extends ServerContainer implements IServerContainer {
 		});
 		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
 
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
+		$this->registerService(\OC\User\Manager::class, function (Server $c) {
 			$config = $c->getConfig();
 			return new \OC\User\Manager($config);
 		});
-		$this->registerAlias('UserManager', \OCP\IUserManager::class);
+		$this->registerAlias('UserManager', \OC\User\Manager::class);
+		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
 
 		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
 			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
@@ -523,7 +524,7 @@ class Server extends ServerContainer implements IServerContainer {
 
 		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
 			return new AvatarManager(
-				$c->getUserManager(),
+				$c->query(\OC\User\Manager::class),
 				$c->getAppDataDir('avatar'),
 				$c->getL10N('lib'),
 				$c->getLogger(),
diff --git a/tests/lib/AvatarManagerTest.php b/tests/lib/AvatarManagerTest.php
index 83a5cfd9b30..9f2a4f4f337 100644
--- a/tests/lib/AvatarManagerTest.php
+++ b/tests/lib/AvatarManagerTest.php
@@ -27,6 +27,7 @@ namespace Test;
 use OC\Avatar;
 use OC\AvatarManager;
 use OC\Files\AppData\AppData;
+use OC\User\Manager;
 use OCP\Files\IAppData;
 use OCP\Files\SimpleFS\ISimpleFolder;
 use OCP\IConfig;
@@ -39,7 +40,7 @@ use OCP\IUserManager;
  * Class AvatarManagerTest
  */
 class AvatarManagerTest extends \Test\TestCase {
-	/** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */
+	/** @var Manager|\PHPUnit_Framework_MockObject_MockObject */
 	private $userManager;
 	/** @var IAppData|\PHPUnit_Framework_MockObject_MockObject */
 	private $appData;
@@ -55,7 +56,7 @@ class AvatarManagerTest extends \Test\TestCase {
 	public function setUp() {
 		parent::setUp();
 
-		$this->userManager = $this->createMock(IUserManager::class);
+		$this->userManager = $this->createMock(Manager::class);
 		$this->appData = $this->createMock(IAppData::class);
 		$this->l10n = $this->createMock(IL10N::class);
 		$this->logger = $this->createMock(ILogger::class);
-- 
GitLab