Files
service_dav/lib/Backends/FilesRootNode.php
T
2026-07-27 00:50:43 -04:00

57 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace KTXM\ServiceDav\Backends;
use KTXC\Context\IdentityContextInterface;
use KTXC\Context\TenantContextInterface;
use KTXM\DocumentsManager\Manager as DocumentsManager;
use Sabre\DAV\Collection;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\INode;
/**
* The root WebDAV collection for a user's files.
*
* Structure: /dav/files/{providerLabel}/{serviceLabel}/...
*
* Each provider+service combination becomes a top-level folder.
*/
class FilesRootNode extends Collection
{
public function __construct(
private readonly DocumentsManager $manager,
private readonly IdentityContextInterface $identityContext,
private readonly TenantContextInterface $tenantContext,
) {}
public function getName(): string
{
return 'files';
}
/** @return INode[] */
public function getChildren(): array
{
$nodes = [];
$services = $this->manager->serviceList($this->tenantContext->identifier(), $this->identityContext->identifier());
foreach ($services as $providerId => $providerServices) {
foreach ($providerServices as $serviceId => $service) {
$nodes[] = new FilesServiceNode(
$service,
);
}
}
return $nodes;
}
public function createDirectory($name): void
{
throw new Forbidden('Cannot create a provider root directory');
}
}