feat: implement node list
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -137,6 +137,54 @@ class RemoteFilesService {
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* list of nodes (folders and files) directly within a location in remote storage
|
||||
*
|
||||
* FileNode/query support is incomplete on some servers (e.g. empty fileNodeQuerySortOptions),
|
||||
* so all nodes are retrieved and the children of the location are selected locally.
|
||||
*
|
||||
* @since 2026.10.01
|
||||
*
|
||||
* @return array{list: array<string,array>, state: string|null}
|
||||
*/
|
||||
public function nodeList(?string $location = null): array {
|
||||
$location = (empty($location) || $location === self::ROOT_ID) ? null : $location;
|
||||
// construct request
|
||||
$r0 = new NodeGet($this->dataAccount, null, $this->resourceNamespace, $this->resourceEntityLabel);
|
||||
// transceive
|
||||
$bundle = $this->dataStore->perform([$r0]);
|
||||
// extract response
|
||||
$response = $bundle->response(0);
|
||||
// check for command error
|
||||
if ($response instanceof ResponseException) {
|
||||
if ($response->type() === 'unknownMethod') {
|
||||
throw new JmapUnknownMethod($response->description(), 1);
|
||||
} else {
|
||||
throw new Exception($response->type() . ': ' . $response->description(), 1);
|
||||
}
|
||||
}
|
||||
// select direct children of location
|
||||
$state = $response->state();
|
||||
$list = [];
|
||||
foreach ($response->objects() as $so) {
|
||||
if (!$so instanceof NodeParametersResponse) {
|
||||
continue;
|
||||
}
|
||||
$parameters = $so->parametersRaw();
|
||||
$parent = $parameters['parentId'] ?? null;
|
||||
if ($parent === self::ROOT_ID) {
|
||||
$parent = null;
|
||||
}
|
||||
if ($parent !== $location) {
|
||||
continue;
|
||||
}
|
||||
$parameters['signature'] = $state;
|
||||
$list[$so->id()] = $parameters;
|
||||
}
|
||||
// return node collection
|
||||
return ['list' => $list, 'state' => $state];
|
||||
}
|
||||
|
||||
/**
|
||||
* fresh instance of collection filter object
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user