aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib/DirectEditingCapabilities.php
blob: 91c1971cec9f9bf19e3bd68bf06f259261f41e56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\Files;

use OCA\Files\Service\DirectEditingService;
use OCP\Capabilities\ICapability;
use OCP\Capabilities\IInitialStateExcludedCapability;
use OCP\IURLGenerator;

class DirectEditingCapabilities implements ICapability, IInitialStateExcludedCapability {
	protected DirectEditingService $directEditingService;
	protected IURLGenerator $urlGenerator;

	public function __construct(DirectEditingService $directEditingService, IURLGenerator $urlGenerator) {
		$this->directEditingService = $directEditingService;
		$this->urlGenerator = $urlGenerator;
	}

	/**
	 * @return array{files: array{directEditing: array{url: string, etag: string, supportsFileId: bool}}}
	 */
	public function getCapabilities() {
		return [
			'files' => [
				'directEditing' => [
					'url' => $this->urlGenerator->linkToOCSRouteAbsolute('files.DirectEditing.info'),
					'etag' => $this->directEditingService->getDirectEditingETag(),
					'supportsFileId' => true,
				]
			],
		];
	}
}