1 | <?php |
||
24 | abstract class FilesService extends Service { |
||
25 | |||
26 | /** @var int */ |
||
27 | protected $virtualRootLevel = null; |
||
28 | /** @var string[] */ |
||
29 | protected $features; |
||
30 | /** @var string */ |
||
31 | protected $ignoreAlbum = '.nomedia'; |
||
32 | |||
33 | /** |
||
34 | * Retrieves all files and sub-folders contained in a folder |
||
35 | * |
||
36 | * If we can't find anything in the current folder, we throw an exception as there is no point |
||
37 | * in doing any more work, but if we're looking at a sub-folder, we return an empty array so |
||
38 | * that it can be simply ignored |
||
39 | * |
||
40 | * @param Folder $folder |
||
41 | * @param int $subDepth |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | 15 | protected function getNodes($folder, $subDepth) { |
|
54 | |||
55 | /** |
||
56 | * Determines if the files are hosted locally (shared or not) and can be used by the preview |
||
57 | * system |
||
58 | * |
||
59 | * isMounted() doesn't include externally hosted shares, so we need to exclude those from the |
||
60 | * non-mounted nodes |
||
61 | * |
||
62 | * @param Node $node |
||
63 | * |
||
64 | * @return bool |
||
65 | */ |
||
66 | 35 | protected function isAllowedAndAvailable($node) { |
|
76 | |||
77 | /** |
||
78 | * Returns the node type, either 'dir' or 'file' |
||
79 | * |
||
80 | * If there is a problem, we return an empty string so that the node can be ignored |
||
81 | * |
||
82 | * @param Node $node |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 14 | protected function getNodeType($node) { |
|
95 | |||
96 | /** |
||
97 | * Returns various information about a node |
||
98 | * |
||
99 | * @param Node|File|Folder $node |
||
100 | * |
||
101 | * @return array<string,int|string|bool|array<string,int|string>> |
||
|
|||
102 | */ |
||
103 | 13 | protected function getNodeData($node) { |
|
118 | |||
119 | /** |
||
120 | * Returns various information about a folder |
||
121 | * |
||
122 | * @param Folder $node |
||
123 | * |
||
124 | * @return array<string,int|string|bool|array<string,int|string>> |
||
125 | */ |
||
126 | 13 | protected function getFolderData($node) { |
|
132 | |||
133 | /** |
||
134 | * Returns the node if it's a folder we have access to |
||
135 | * |
||
136 | * @param Folder $node |
||
137 | * @param string $nodeType |
||
138 | * |
||
139 | * @return array|Folder |
||
140 | */ |
||
141 | 14 | protected function getAllowedSubFolder($node, $nodeType) { |
|
151 | |||
152 | /** |
||
153 | * Determines if we've reached the root folder |
||
154 | * |
||
155 | * @param Folder $folder |
||
156 | * @param int $level |
||
157 | * |
||
158 | * @return bool |
||
159 | */ |
||
160 | 5 | protected function isRootFolder($folder, $level) { |
|
173 | |||
174 | /** |
||
175 | * Throws an exception if this problem occurs in the current folder, otherwise just ignores the |
||
176 | * sub-folder |
||
177 | * |
||
178 | * @param int $subDepth |
||
179 | * @param \Exception $exception |
||
180 | * |
||
181 | * @return array |
||
182 | * @throws NotFoundServiceException |
||
183 | */ |
||
184 | 4 | private function recoverFromGetNodesError($subDepth, $exception) { |
|
191 | |||
192 | /** |
||
193 | * Determines if we can consider the node mounted locally or if it's been authorised to be |
||
194 | * scanned |
||
195 | * |
||
196 | * @param Node $node |
||
197 | * |
||
198 | * @return bool |
||
199 | */ |
||
200 | 34 | private function isAllowed($node) { |
|
213 | |||
214 | /** |
||
215 | * Determines if the node is available, as in readable |
||
216 | * |
||
217 | * @todo Test to see by how much using file_exists slows things down |
||
218 | * |
||
219 | * @param Node $node |
||
220 | * |
||
221 | * @return bool |
||
222 | */ |
||
223 | 31 | private function isAvailable($node) { |
|
226 | |||
227 | /** |
||
228 | * Determines if the user has allowed the use of external shares |
||
229 | * |
||
230 | * @return bool |
||
231 | */ |
||
232 | 6 | private function isExternalShareAllowed() { |
|
238 | |||
239 | /** |
||
240 | * Determines if the node is a share which is hosted externally |
||
241 | * |
||
242 | * |
||
243 | * @param Node $node |
||
244 | * |
||
245 | * @return bool |
||
246 | */ |
||
247 | 34 | private function isExternalShare($node) { |
|
256 | |||
257 | /** |
||
258 | * Returns an array containing information about a node |
||
259 | * |
||
260 | * @param string $imagePath |
||
261 | * @param int $nodeId |
||
262 | * @param int $mTime |
||
263 | * @param string $etag |
||
264 | * @param int $size |
||
265 | * @param bool $sharedWithUser |
||
266 | * @param int $permissions |
||
267 | * |
||
268 | * @return array |
||
269 | */ |
||
270 | 13 | private function formatNodeData( |
|
283 | |||
284 | } |
||
285 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.