0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-22 04:38:09 +01:00
organization_folders/lib/Manager/PathManager.php

41 lines
1.2 KiB
PHP
Raw Normal View History

2024-11-04 19:24:12 +01:00
<?php
namespace OCA\OrganizationFolders\Manager;
use OCP\IConfig;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\Folder;
use OCA\GroupFolders\Folder\FolderManager;
use OCA\GroupFolders\Mount\MountProvider;
use OCA\OrganizationFolders\Db\FolderResource;
use OCA\OrganizationFolders\Model\OrganizationFolder;
class PathManager {
public function __construct(
private IConfig $config,
private IRootFolder $rootFolder,
private FolderManager $groupfolderFolderManager,
private MountProvider $mountProvider,
){}
private function getRootFolderStorageId(): ?int {
return $this->rootFolder->getMountPoint()->getNumericStorageId();
}
public function getOrganizationFolderNode(OrganizationFolder $organizationFolder): ?Folder {
return $this->getOrganizationFolderNodeById($organizationFolder->getId());
}
public function getOrganizationFolderNodeById(int $id): ?Folder {
return $this->mountProvider->getFolder($id, False);
}
public function getFolderResourceNode(FolderResource $resource): ?Folder {
$organizationFolderNode = $this->getOrganizationFolderNodeById($resource->getOrganizationFolderId());
return $organizationFolderNode->getFirstNodeById($resource->getFileId());
}
}