mirror of
https://github.com/nextcloud/server.git
synced 2026-11-04 22:17:32 +01:00
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>
60 lines
1.1 KiB
PHP
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;
|
|
}
|
|
}
|