diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-07-25 18:57:22 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-08-02 09:39:39 +0300 |
commit | 02d687073578945390eb69cc8074f0d688195d5d (patch) | |
tree | e3b32024e37e9c9d99243c7a0708ad97c885d899 /apps/files_external/lib | |
parent | a2c5ab2f8ba66cf5e9a65bb6dcc232675c31f034 (diff) |
fixes terminology and allows to request an IUser instance
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/Config/UserContext.php | 27 | ||||
-rw-r--r-- | apps/files_external/lib/config.php | 3 |
2 files changed, 23 insertions, 7 deletions
diff --git a/apps/files_external/lib/Config/UserContext.php b/apps/files_external/lib/Config/UserContext.php index bec762358f2..12621d22f5e 100644 --- a/apps/files_external/lib/Config/UserContext.php +++ b/apps/files_external/lib/Config/UserContext.php @@ -24,6 +24,8 @@ namespace OCA\Files_External\Config; use OCP\IRequest; +use OCP\IUser; +use OCP\IUserManager; use OCP\IUserSession; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager as ShareManager; @@ -39,25 +41,30 @@ class UserContext { /** @var IRequest */ private $request; - private $user; + /** @var string */ + private $userId; - public function __construct(IUserSession $session, ShareManager $manager, IRequest $request) { + /** @var IUserManager */ + private $userManager; + + public function __construct(IUserSession $session, ShareManager $manager, IRequest $request, IUserManager $userManager) { $this->session = $session; $this->shareManager = $manager; $this->request = $request; + $this->userManager = $userManager; } public function getSession(): IUserSession { return $this->session; } - public function setUser($user): void { - $this->user = $user; + public function setUserId(string $userId): void { + $this->userId = $userId; } protected function getUserId(): ?string { - if ($this->user !== null) { - return $this->user; + if ($this->userId !== null) { + return $this->userId; } if($this->session && $this->session->getUser() !== null) { return $this->session->getUser()->getUID(); @@ -71,4 +78,12 @@ class UserContext { return null; } + protected function getUser(): ?IUser { + $userId = $this->getUserId(); + if($userId !== null) { + return $this->userManager->get($userId); + } + return null; + } + } diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index cc0096d6dbf..85bbbeb57d9 100644 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -212,11 +212,12 @@ class OC_Mount_Config { /** * @param mixed $input + * @param string|null $userId * @return mixed * @throws \OCP\AppFramework\QueryException * @since 16.0.0 */ - public static function substitutePlaceholdersInConfig($input, $user = null) { + public static function substitutePlaceholdersInConfig($input, string $userId = null) { /** @var BackendService $backendService */ $backendService = self::$app->getContainer()->query(BackendService::class); /** @var IConfigHandler[] $handlers */ |