HomeObjectStoreStorage.php 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\Files\ObjectStore;
  8. use Exception;
  9. use OCP\Files\IHomeStorage;
  10. use OCP\IUser;
  11. class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage {
  12. protected IUser $user;
  13. /**
  14. * The home user storage requires a user object to create a unique storage id
  15. *
  16. * @param array $params
  17. * @throws Exception
  18. */
  19. public function __construct($params) {
  20. if (! isset($params['user']) || ! $params['user'] instanceof IUser) {
  21. throw new Exception('missing user object in parameters');
  22. }
  23. $this->user = $params['user'];
  24. parent::__construct($params);
  25. }
  26. public function getId(): string {
  27. return 'object::user:' . $this->user->getUID();
  28. }
  29. public function getOwner($path): string|false {
  30. return $this->user->getUID();
  31. }
  32. public function getUser(): IUser {
  33. return $this->user;
  34. }
  35. }