diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2015-12-01 22:08:42 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2015-12-01 22:15:43 +0100 |
commit | b00db2c9334874c6062a143de2a6b76b44dca35d (patch) | |
tree | db13d5d23114468e978786cc52031dc31c312584 /lib/private/avatarmanager.php | |
parent | 8931ba4a0d574a05cf4415f2556bdd3ee0388ba9 (diff) | |
download | nextcloud-server-b00db2c9334874c6062a143de2a6b76b44dca35d.tar.gz nextcloud-server-b00db2c9334874c6062a143de2a6b76b44dca35d.zip |
DI in avatar code
* DI in avatar code
* Use the node API
* More unit tests
* Unit tests no longer require DB
Diffstat (limited to 'lib/private/avatarmanager.php')
-rw-r--r-- | lib/private/avatarmanager.php | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/private/avatarmanager.php b/lib/private/avatarmanager.php index 143874b6be3..6969b386e15 100644 --- a/lib/private/avatarmanager.php +++ b/lib/private/avatarmanager.php @@ -27,13 +27,33 @@ namespace OC; use OCP\IAvatarManager; -use OC\Avatar; +use OCP\IUserManager; +use OCP\Files\IRootFolder; +use OCP\IL10N; /** * This class implements methods to access Avatar functionality */ class AvatarManager implements IAvatarManager { + /** @var IUserManager */ + private $userManager; + + /** @var IRootFolder */ + private $rootFolder; + + /** @var IL10N */ + private $l; + + public function __construct( + IUserManager $userManager, + IRootFolder $rootFolder, + IL10N $l) { + $this->userManager = $userManager; + $this->rootFolder = $rootFolder; + $this->l = $l; + } + /** * return a user specific instance of \OCP\IAvatar * @see \OCP\IAvatar @@ -42,6 +62,9 @@ class AvatarManager implements IAvatarManager { * @throws \Exception In case the username is potentially dangerous */ public function getAvatar($user) { - return new Avatar($user); + if (!$this->userManager->userExists($user)) { + throw new \Exception('user does not exist'); + } + return new Avatar($this->rootFolder->getUserFolder($user)->getParent(), $this->l); } } |