HomeObjectStoreStorage.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Citharel <nextcloud@tcit.fr>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OC\Files\ObjectStore;
  28. use Exception;
  29. use OCP\Files\IHomeStorage;
  30. use OCP\IUser;
  31. class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage {
  32. protected IUser $user;
  33. /**
  34. * The home user storage requires a user object to create a unique storage id
  35. *
  36. * @param array $params
  37. * @throws Exception
  38. */
  39. public function __construct($params) {
  40. if (! isset($params['user']) || ! $params['user'] instanceof IUser) {
  41. throw new Exception('missing user object in parameters');
  42. }
  43. $this->user = $params['user'];
  44. parent::__construct($params);
  45. }
  46. public function getId(): string {
  47. return 'object::user:' . $this->user->getUID();
  48. }
  49. /**
  50. * get the owner of a path
  51. *
  52. * @param string $path The path to get the owner
  53. * @return string uid
  54. */
  55. public function getOwner($path): string {
  56. return $this->user->getUID();
  57. }
  58. public function getUser(): IUser {
  59. return $this->user;
  60. }
  61. }