generated from Nodarx/template
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXM\ServiceDav\Backends;
|
|
|
|
use KTXC\SessionIdentity;
|
|
use KTXC\SessionTenant;
|
|
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 SessionIdentity $identity,
|
|
private readonly SessionTenant $tenant,
|
|
) {}
|
|
|
|
public function getName(): string
|
|
{
|
|
return 'files';
|
|
}
|
|
|
|
/** @return INode[] */
|
|
public function getChildren(): array
|
|
{
|
|
$nodes = [];
|
|
$services = $this->manager->serviceList($this->tenant->identifier(), $this->identity->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');
|
|
}
|
|
}
|