Files
nextcloud-server-mirror/lib/unstable/Files/NodeAttributes/NodeAttributeContext.php
John Molakvoæ 9b9757d721 feat: add node attribute providers for WebDAV and PHP
Apps register INodeAttributeProvider with the attributes they serve, in
Clark notation. INodeSerializer returns nodes with those attributes in
the shape @nextcloud/files uses, so PHP code gets the same file data as
a PROPFIND.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
2026-10-16 17:52:43 +02:00

60 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace NCU\Files\NodeAttributes;
use OCP\IUser;
use OCP\Share\IShare;
/**
* Who the attributes are provided for: a logged in user,
* or a visitor of a public share who only has the share.
*
* @experimental 36.0.0
*/
final class NodeAttributeContext {
private function __construct(
private readonly ?IUser $user,
private readonly ?IShare $share,
) {
}
/**
* @experimental 36.0.0
*/
public static function forUser(IUser $user): self {
return new self($user, null);
}
/**
* @experimental 36.0.0
*/
public static function forShare(IShare $share): self {
return new self(null, $share);
}
/**
* The logged in user, null on public shares
*
* @experimental 36.0.0
*/
public function getUser(): ?IUser {
return $this->user;
}
/**
* The public share, null for logged in users
*
* @experimental 36.0.0
*/
public function getShare(): ?IShare {
return $this->share;
}
}