PublicShareWrapper.php 940 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Storage;
  8. use OC\Files\Storage\Wrapper\Wrapper;
  9. use OCP\Files\Storage\ISharedStorage;
  10. use OCP\Share\IShare;
  11. class PublicShareWrapper extends Wrapper implements ISharedStorage {
  12. private IShare $share;
  13. /**
  14. * @param array $arguments ['storage' => $storage, 'share' => $share]
  15. *
  16. * $storage: The storage the permissions mask should be applied on
  17. * $share: The share to use in case no share is found
  18. */
  19. public function __construct($arguments) {
  20. parent::__construct($arguments);
  21. $this->share = $arguments['share'];
  22. }
  23. public function getShare(): IShare {
  24. $storage = parent::getWrapperStorage();
  25. if (method_exists($storage, 'getShare')) {
  26. /** @var ISharedStorage $storage */
  27. return $storage->getShare();
  28. }
  29. return $this->share;
  30. }
  31. }