Mount.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. use OCA\Files_Sharing\ISharedMountPoint;
  29. class Mount extends MountPoint implements MoveableMount, ISharedMountPoint {
  30. /**
  31. * @var \OCA\Files_Sharing\External\Manager
  32. */
  33. protected $manager;
  34. /**
  35. * @param string|\OC\Files\Storage\Storage $storage
  36. * @param string $mountpoint
  37. * @param array $options
  38. * @param \OCA\Files_Sharing\External\Manager $manager
  39. * @param \OC\Files\Storage\StorageFactory $loader
  40. */
  41. public function __construct($storage, $mountpoint, $options, $manager, $loader = null) {
  42. parent::__construct($storage, $mountpoint, $options, $loader, null, null, MountProvider::class);
  43. $this->manager = $manager;
  44. }
  45. /**
  46. * Move the mount point to $target
  47. *
  48. * @param string $target the target mount point
  49. * @return bool
  50. */
  51. public function moveMount($target) {
  52. $result = $this->manager->setMountPoint($this->mountPoint, $target);
  53. $this->setMountPoint($target);
  54. return $result;
  55. }
  56. /**
  57. * Remove the mount points
  58. */
  59. public function removeMount(): bool {
  60. return $this->manager->removeShare($this->mountPoint);
  61. }
  62. /**
  63. * Get the type of mount point, used to distinguish things like shares and external storage
  64. * in the web interface
  65. *
  66. * @return string
  67. */
  68. public function getMountType() {
  69. return 'shared';
  70. }
  71. }