|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors |
| 5 | + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. |
| 6 | + * SPDX-License-Identifier: AGPL-3.0-only |
| 7 | + */ |
| 8 | +namespace OC\Files\Mount; |
| 9 | + |
| 10 | +use OCP\Files\Mount\IMountPoint; |
| 11 | + |
| 12 | +class LazyMountPoint implements IMountPoint { |
| 13 | + private ?IMountPoint $mountPoint = null; |
| 14 | + |
| 15 | + /** |
| 16 | + * @param \Closure(): IMountPoint $mountPointClosure |
| 17 | + */ |
| 18 | + public function __construct( |
| 19 | + private readonly \Closure $mountPointClosure, |
| 20 | + private readonly array $data, |
| 21 | + ) { |
| 22 | + } |
| 23 | + |
| 24 | + private function getRealMountPoint(): IMountPoint { |
| 25 | + if ($this->mountPoint === null) { |
| 26 | + $this->mountPoint = call_user_func($this->mountPointClosure); |
| 27 | + } |
| 28 | + return $this->mountPoint; |
| 29 | + } |
| 30 | + |
| 31 | + public function __call($method, $args) { |
| 32 | + return call_user_func_array([$this->getRealMountPoint(), $method], $args); |
| 33 | + } |
| 34 | + |
| 35 | + public function getMountPoint() { |
| 36 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 37 | + } |
| 38 | + |
| 39 | + public function setMountPoint($mountPoint) { |
| 40 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 41 | + } |
| 42 | + |
| 43 | + private function createStorage() { |
| 44 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 45 | + } |
| 46 | + |
| 47 | + public function getStorage() { |
| 48 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 49 | + } |
| 50 | + |
| 51 | + public function getStorageId(): ?string { |
| 52 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 53 | + } |
| 54 | + |
| 55 | + public function getNumericStorageId(): int { |
| 56 | + if (isset($this->data['numericStorageId'])) { |
| 57 | + return $this->data['numericStorageId']; |
| 58 | + } |
| 59 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 60 | + } |
| 61 | + |
| 62 | + public function getInternalPath($path) { |
| 63 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 64 | + } |
| 65 | + |
| 66 | + public function wrapStorage($wrapper): void { |
| 67 | + $this->__call(__FUNCTION__, func_get_args()); |
| 68 | + } |
| 69 | + |
| 70 | + public function getOption($name, $default) { |
| 71 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 72 | + } |
| 73 | + |
| 74 | + public function getOptions(): array { |
| 75 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 76 | + } |
| 77 | + |
| 78 | + public function getStorageRootId(): int { |
| 79 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 80 | + } |
| 81 | + |
| 82 | + public function getMountId() { |
| 83 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 84 | + } |
| 85 | + |
| 86 | + public function getMountType() { |
| 87 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 88 | + } |
| 89 | + |
| 90 | + public function getMountProvider(): string { |
| 91 | + return $this->__call(__FUNCTION__, func_get_args()); |
| 92 | + } |
| 93 | +} |
0 commit comments