PublicShareWrapper.php 950 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 $parameters ['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(array $parameters) {
  20. parent::__construct($parameters);
  21. $this->share = $parameters['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. }