summaryrefslogtreecommitdiffstats
path: root/lib/private/Avatar/AvatarManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Avatar/AvatarManager.php')
-rw-r--r--lib/private/Avatar/AvatarManager.php59
1 files changed, 11 insertions, 48 deletions
diff --git a/lib/private/Avatar/AvatarManager.php b/lib/private/Avatar/AvatarManager.php
index 4125c8eb0a8..d3594a2bffe 100644
--- a/lib/private/Avatar/AvatarManager.php
+++ b/lib/private/Avatar/AvatarManager.php
@@ -55,59 +55,26 @@ use Psr\Log\LoggerInterface;
* This class implements methods to access Avatar functionality
*/
class AvatarManager implements IAvatarManager {
- /** @var IUserSession */
- private $userSession;
-
- /** @var Manager */
- private $userManager;
-
- /** @var IAppData */
- private $appData;
-
- /** @var IL10N */
- private $l;
-
- /** @var LoggerInterface */
- private $logger;
-
- /** @var IConfig */
- private $config;
-
- /** @var IAccountManager */
- private $accountManager;
-
- /** @var KnownUserService */
- private $knownUserService;
-
public function __construct(
- IUserSession $userSession,
- Manager $userManager,
- IAppData $appData,
- IL10N $l,
- LoggerInterface $logger,
- IConfig $config,
- IAccountManager $accountManager,
- KnownUserService $knownUserService
+ private IUserSession $userSession,
+ private Manager $userManager,
+ private IAppData $appData,
+ private IL10N $l,
+ private LoggerInterface $logger,
+ private IConfig $config,
+ private IAccountManager $accountManager,
+ private KnownUserService $knownUserService,
) {
- $this->userSession = $userSession;
- $this->userManager = $userManager;
- $this->appData = $appData;
- $this->l = $l;
- $this->logger = $logger;
- $this->config = $config;
- $this->accountManager = $accountManager;
- $this->knownUserService = $knownUserService;
}
/**
* return a user specific instance of \OCP\IAvatar
* @see \OCP\IAvatar
* @param string $userId the ownCloud user id
- * @return \OCP\IAvatar
* @throws \Exception In case the username is potentially dangerous
* @throws NotFoundException In case there is no user folder yet
*/
- public function getAvatar(string $userId) : IAvatar {
+ public function getAvatar(string $userId): IAvatar {
$user = $this->userManager->get($userId);
if ($user === null) {
throw new \Exception('user does not exist');
@@ -116,10 +83,7 @@ class AvatarManager implements IAvatarManager {
// sanitize userID - fixes casing issue (needed for the filesystem stuff that is done below)
$userId = $user->getUID();
- $requestingUser = null;
- if ($this->userSession !== null) {
- $requestingUser = $this->userSession->getUser();
- }
+ $requestingUser = $this->userSession?->getUser();
try {
$folder = $this->appData->getFolder($userId);
@@ -157,7 +121,7 @@ class AvatarManager implements IAvatarManager {
/**
* Clear generated avatars
*/
- public function clearCachedAvatars() {
+ public function clearCachedAvatars(): void {
$users = $this->config->getUsersForUserValue('avatar', 'generated', 'true');
foreach ($users as $userId) {
// This also bumps the avatar version leading to cache invalidation in browsers
@@ -183,7 +147,6 @@ class AvatarManager implements IAvatarManager {
* Returns a GuestAvatar.
*
* @param string $name The guest name, e.g. "Albert".
- * @return IAvatar
*/
public function getGuestAvatar(string $name): IAvatar {
return new GuestAvatar($name, $this->logger);