on('propFind', $this->propFind(...)); } public function propFind(PropFind $propFind, INode $node): void { if (!$node instanceof Node) { return; } $fileInfo = $node->getFileInfo(); $mount = $fileInfo->getMountPoint(); if (!$mount instanceof GroupMountPoint) { return; } /** * @var ?OrganizationFolder */ $organizationFolder = null; /** * @var ?Resource */ $resource = null; $propFind->handle(self::ORGANIZATION_FOLDER_ID_PROPERTYNAME, function () use ($fileInfo, $organizationFolder): ?int { try { if(!isset($organizationFolder)) { $organizationFolder = $this->getOrganizationFolderFromPath($fileInfo->getPath()); } return $organizationFolder->getId(); } catch (\Exception $e) { return null; } }); $propFind->handle(self::ORGANIZATION_FOLDER_UPDATE_PERMISSIONS_PROPERTYNAME, function () use ($fileInfo, $organizationFolder): ?string { try { if(!isset($organizationFolder)) { $organizationFolder = $this->getOrganizationFolderFromPath($fileInfo->getPath()); } return $this->authorizationService->isGranted(["UPDATE"], $organizationFolder) ? 'true' : 'false'; } catch (\Exception $e) { return null; } }); $propFind->handle(self::ORGANIZATION_FOLDER_RESOURCE_ID_PROPERTYNAME, function () use ($node, $resource): ?int { try { if(!isset($resource)) { $resource = $this->resourceService->findByFileId($node->getId()); } return $resource->getId(); } catch (\Exception $e) { return null; } }); $propFind->handle(self::ORGANIZATION_FOLDER_RESOURCE_UPDATE_PERMISSIONS_PROPERTYNAME, function () use ($node, $resource) { try { if(!isset($resource)) { $resource = $this->resourceService->findByFileId($node->getId()); } return $this->authorizationService->isGranted(["UPDATE"], $resource) ? 'true' : 'false'; } catch (\Exception $e) { return null; } }); } private function getOrganizationFolderFromPath($path): ?OrganizationFolder { $organizationFolderId = $this->folderManager->getFolderByPath($path); if(isset($organizationFolderId)) { return $this->organizationFolderService->find($organizationFolderId); } else { return null; } } }