Mount.php 2.1 KB

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