HomeObjectStoreStorage.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. /**
  30. * get the owner of a path
  31. *
  32. * @param string $path The path to get the owner
  33. * @return string uid
  34. */
  35. public function getOwner($path): string {
  36. return $this->user->getUID();
  37. }
  38. public function getUser(): IUser {
  39. return $this->user;
  40. }
  41. }