1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* FullTextSearch_ElasticSearch - Use Elasticsearch to index the content of your nextcloud |
7
|
|
|
* |
8
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
9
|
|
|
* later. See the COPYING file. |
10
|
|
|
* |
11
|
|
|
* @author Robin Windey <[email protected]> |
12
|
|
|
* @copyright 2020 |
13
|
|
|
* @license GNU AGPL version 3 or any later version |
14
|
|
|
* |
15
|
|
|
* This program is free software: you can redistribute it and/or modify |
16
|
|
|
* it under the terms of the GNU Affero General Public License as |
17
|
|
|
* published by the Free Software Foundation, either version 3 of the |
18
|
|
|
* License, or (at your option) any later version. |
19
|
|
|
* |
20
|
|
|
* This program is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU Affero General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* You should have received a copy of the GNU Affero General Public License |
26
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
27
|
|
|
* |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
namespace OCA\FullTextSearch_ElasticSearch\Service; |
31
|
|
|
|
32
|
|
|
use OCA\Files_External\Service\UserGlobalStoragesService; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Wrapper class for native OCA\Files_External\Service\UserGlobalStoragesService |
36
|
|
|
*/ |
37
|
|
|
class UserStoragesService implements IUserStoragesService { |
38
|
|
|
|
39
|
|
|
/** @var UserGlobalStoragesService */ |
40
|
|
|
private $userGlobalStoragesService; |
41
|
|
|
|
42
|
|
|
function __construct(UserGlobalStoragesService $userGlobalStoragesService) { |
|
|
|
|
43
|
|
|
$this->userGlobalStoragesService = $userGlobalStoragesService; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Returns an array of strings with all external mountpoints of the current user |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
|
|
function getAllStoragesForUser() { |
|
|
|
|
51
|
|
|
$userStorages = $this->userGlobalStoragesService->getAllStoragesForUser(); |
52
|
|
|
$mountPoints = []; |
53
|
|
|
foreach($userStorages as $userStorage){ |
54
|
|
|
/** @var $userStorage OCA\Files_External\Lib\StorageConfig */ |
55
|
|
|
$mountPoint = $userStorage->getMountPoint(); |
56
|
|
|
if (substr($mountPoint, 0, 1) === '/'){ |
57
|
|
|
$mountPoint = substr($mountPoint, 1, strlen($mountPoint) - 1); |
58
|
|
|
} |
59
|
|
|
if (substr($mountPoint, strlen($mountPoint) - 1, 1) !== '/'){ |
60
|
|
|
$mountPoint .= '/'; |
61
|
|
|
} |
62
|
|
|
$mountPoints[] = $mountPoint; |
63
|
|
|
} |
64
|
|
|
return $mountPoints; |
65
|
|
|
} |
66
|
|
|
} |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.