principalInfo['uri']); return $name; } public function setName($name): never { throw new Forbidden('Permission denied to rename this folder'); } public function createFile($name, $data = null): never { throw new Forbidden('Not allowed to create files in this folder'); } public function createDirectory($name): never { throw new Forbidden('Permission denied to create folders in this folder'); } /** * @return ?FolderDefinition */ private function getFolder(string $name): ?FolderDefinition { $storageId = $this->rootFolder->getMountPoint()->getNumericStorageId(); if ($storageId === null) { return null; } $folders = $this->folderManager->getFoldersForUser($this->user); foreach ($folders as $folder) { if (basename($folder->mountPoint) === $name) { return $folder; } } return null; } private function getDirectoryForFolder(FolderDefinition $folder): GroupFolderNode { $userHome = '/' . $this->user->getUID() . '/files'; $node = $this->rootFolder->get($userHome . '/' . $folder->mountPoint); $view = Filesystem::getView(); if ($view === null) { throw new RuntimeException('Unable to create view.'); } return new GroupFolderNode($view, $node, $folder->id); } public function getChild($name): GroupFolderNode { $folder = $this->getFolder($name); if ($folder) { return $this->getDirectoryForFolder($folder); } throw new NotFound(); } /** * @return GroupFolderNode[] */ public function getChildren(): array { $storageId = $this->rootFolder->getMountPoint()->getNumericStorageId(); if ($storageId === null) { return []; } $folders = $this->folderManager->getFoldersForUser($this->user); // Filter out non top-level folders $folders = array_filter($folders, function (FolderDefinition $folder) { return !str_contains($folder->mountPoint, '/'); }); return array_map($this->getDirectoryForFolder(...), $folders); } public function childExists($name): bool { return $this->getFolder($name) !== null; } public function getLastModified(): int { return 0; } }