Mount.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_Sharing\External;
  8. use OC\Files\Mount\MountPoint;
  9. use OC\Files\Mount\MoveableMount;
  10. use OC\Files\Storage\Storage;
  11. use OCA\Files_Sharing\ISharedMountPoint;
  12. class Mount extends MountPoint implements MoveableMount, ISharedMountPoint {
  13. /**
  14. * @param string|Storage $storage
  15. * @param string $mountpoint
  16. * @param array $options
  17. * @param \OCA\Files_Sharing\External\Manager $manager
  18. * @param \OC\Files\Storage\StorageFactory $loader
  19. */
  20. public function __construct(
  21. $storage,
  22. $mountpoint,
  23. $options,
  24. protected $manager,
  25. $loader = null,
  26. ) {
  27. parent::__construct($storage, $mountpoint, $options, $loader, null, null, MountProvider::class);
  28. }
  29. /**
  30. * Move the mount point to $target
  31. *
  32. * @param string $target the target mount point
  33. * @return bool
  34. */
  35. public function moveMount($target) {
  36. $result = $this->manager->setMountPoint($this->mountPoint, $target);
  37. $this->setMountPoint($target);
  38. return $result;
  39. }
  40. /**
  41. * Remove the mount points
  42. */
  43. public function removeMount(): bool {
  44. return $this->manager->removeShare($this->mountPoint);
  45. }
  46. /**
  47. * Get the type of mount point, used to distinguish things like shares and external storage
  48. * in the web interface
  49. *
  50. * @return string
  51. */
  52. public function getMountType() {
  53. return 'shared';
  54. }
  55. }