setAccessible(true); $view = $rp->getValue($folder); // Get the subfolders $folders = $view->getDirectoryContent($folder->getPath(), FileInfo::MIMETYPE_FOLDER, $folder); // Sort by name usort($folders, fn ($a, $b) => strnatcmp($a->getName(), $b->getName())); // Process to response type return [ 'dayid' => \OCA\Memories\Util::$TAG_DAYID_FOLDERS, 'count' => \count($folders), 'detail' => array_map(function ($node) use (&$folder) { return [ 'fileid' => $node->getId(), 'name' => $node->getName(), 'isfolder' => 1, 'path' => $node->getPath(), 'previews' => $this->getFolderPreviews($folder, $node), ]; }, $folders, []), ]; } private function getFolderPreviews(Folder &$parent, FileInfo &$fileInfo) { $folder = $parent->getById($fileInfo->getId()); if (0 === \count($folder)) { return []; } return $this->timelineQuery->getFolderPreviews($folder[0]); } }