|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | +/** |
| 5 | + * SPDX-FileCopyrightText: 2025 LibreCode coop and contributors |
| 6 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | + */ |
| 8 | + |
| 9 | +namespace OCA\Libresign; |
| 10 | + |
| 11 | +use OCA\Libresign\Service\SignatureTextService; |
| 12 | +use OCA\Libresign\Service\SignerElementsService; |
| 13 | +use OCP\App\IAppManager; |
| 14 | +use OCP\Capabilities\IPublicCapability; |
| 15 | + |
| 16 | +/** |
| 17 | + * @psalm-import-type LibresignCapabilities from ResponseDefinitions |
| 18 | + */ |
| 19 | +class Capabilities implements IPublicCapability { |
| 20 | + public const FEATURES = [ |
| 21 | + 'customize-signature' |
| 22 | + ]; |
| 23 | + |
| 24 | + public function __construct( |
| 25 | + protected SignerElementsService $signerElementsService, |
| 26 | + protected SignatureTextService $signatureTextService, |
| 27 | + protected IAppManager $appManager, |
| 28 | + ) { |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * @return array{ |
| 33 | + * libresign?: LibresignCapabilities, |
| 34 | + * } |
| 35 | + */ |
| 36 | + public function getCapabilities(): array { |
| 37 | + $capabilities = [ |
| 38 | + 'features' => self::FEATURES, |
| 39 | + 'config' => [ |
| 40 | + 'sign-elements' => [ |
| 41 | + 'is-available' => $this->signerElementsService->isSignElementsAvailable(), |
| 42 | + 'can-create-signature' => $this->signerElementsService->canCreateSignature(), |
| 43 | + 'full-signature-width' => $this->signatureTextService->getFullSignatureWidth(), |
| 44 | + 'full-signature-height' => $this->signatureTextService->getFullSignatureHeight(), |
| 45 | + 'signature-width' => $this->signatureTextService->getSignatureWidth(), |
| 46 | + 'signature-height' => $this->signatureTextService->getSignatureHeight(), |
| 47 | + ], |
| 48 | + ], |
| 49 | + 'version' => $this->appManager->getAppVersion('libresign'), |
| 50 | + ]; |
| 51 | + |
| 52 | + return [ |
| 53 | + 'libresign' => $capabilities, |
| 54 | + ]; |
| 55 | + } |
| 56 | +} |
0 commit comments