mirror of
https://github.com/nextcloud/server.git
synced 2026-11-18 09:54:41 +01:00
A Sabre plugin serves the registered attributes on remote.php, /webdav and the public endpoints, preloading collections and search results at once. has-preview and favorite move from FilesPlugin and TagsPlugin to providers, so WebDAV and the serializer share one implementation. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
39 lines
987 B
PHP
39 lines
987 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OCA\DAV\Files\NodeAttributes;
|
|
|
|
use NCU\Files\NodeAttributes\INodeAttributeProvider;
|
|
use NCU\Files\NodeAttributes\NodeAttributeContext;
|
|
use OCA\DAV\Connector\Sabre\FilesPlugin;
|
|
use OCP\Files\Node;
|
|
use OCP\IPreview;
|
|
|
|
/**
|
|
* Whether a preview can be generated for a node
|
|
*/
|
|
class HasPreviewProvider implements INodeAttributeProvider {
|
|
public function __construct(
|
|
private readonly IPreview $previewManager,
|
|
) {
|
|
}
|
|
|
|
#[\Override]
|
|
public function preload(NodeAttributeContext $context, array $nodes, array $attributes): void {
|
|
// Previews availability only depends on the node itself
|
|
}
|
|
|
|
#[\Override]
|
|
public function getAttributes(NodeAttributeContext $context, Node $node, array $attributes): array {
|
|
return [
|
|
FilesPlugin::HAS_PREVIEW_PROPERTYNAME => $this->previewManager->isAvailable($node),
|
|
];
|
|
}
|
|
}
|