Mount.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Björn Schießle <bjoern@schiessle.org>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author szaimen <szaimen@e.mail.de>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OCA\Files_Sharing\External;
  26. use OC\Files\Mount\MountPoint;
  27. use OC\Files\Mount\MoveableMount;
  28. class Mount extends MountPoint implements MoveableMount {
  29. /**
  30. * @var \OCA\Files_Sharing\External\Manager
  31. */
  32. protected $manager;
  33. /**
  34. * @param string|\OC\Files\Storage\Storage $storage
  35. * @param string $mountpoint
  36. * @param array $options
  37. * @param \OCA\Files_Sharing\External\Manager $manager
  38. * @param \OC\Files\Storage\StorageFactory $loader
  39. */
  40. public function __construct($storage, $mountpoint, $options, $manager, $loader = null) {
  41. parent::__construct($storage, $mountpoint, $options, $loader, null, null, MountProvider::class);
  42. $this->manager = $manager;
  43. }
  44. /**
  45. * Move the mount point to $target
  46. *
  47. * @param string $target the target mount point
  48. * @return bool
  49. */
  50. public function moveMount($target) {
  51. $result = $this->manager->setMountPoint($this->mountPoint, $target);
  52. $this->setMountPoint($target);
  53. return $result;
  54. }
  55. /**
  56. * Remove the mount points
  57. */
  58. public function removeMount(): bool {
  59. return $this->manager->removeShare($this->mountPoint);
  60. }
  61. /**
  62. * Get the type of mount point, used to distinguish things like shares and external storage
  63. * in the web interface
  64. *
  65. * @return string
  66. */
  67. public function getMountType() {
  68. return 'shared';
  69. }
  70. }