-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathTemplateLoader.php
More file actions
72 lines (63 loc) · 2.14 KB
/
TemplateLoader.php
File metadata and controls
72 lines (63 loc) · 2.14 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Libresign\Files;
use OCA\Files\Event\LoadSidebar;
use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Exception\LibresignException;
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
use OCA\Libresign\Helper\ValidateHelper;
use OCA\Libresign\Service\AccountService;
use OCA\Libresign\Service\IdentifyMethodService;
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
use OCP\IAppConfig;
use OCP\IRequest;
use OCP\IUserSession;
/**
* @template-implements IEventListener<Event>
*/
class TemplateLoader implements IEventListener {
public function __construct(
private IRequest $request,
private IUserSession $userSession,
private AccountService $accountService,
private IInitialState $initialState,
private ValidateHelper $validateHelper,
private IdentifyMethodService $identifyMethodService,
private CertificateEngineFactory $certificateEngineFactory,
private IAppConfig $appConfig,
) {
}
public static function register(IEventDispatcher $dispatcher): void {
$dispatcher->addServiceListener(LoadSidebar::class, self::class);
}
public function handle(Event $event): void {
if (!($event instanceof LoadSidebar)) {
return;
}
$this->initialState->provideInitialState(
'certificate_ok',
$this->certificateEngineFactory->getEngine()->isSetupOk()
);
$this->initialState->provideInitialState(
'identify_methods',
$this->identifyMethodService->getIdentifyMethodsSettings()
);
$this->initialState->provideInitialState(
'signature_flow',
$this->appConfig->getValueString(Application::APP_ID, 'signature_flow', \OCA\Libresign\Enum\SignatureFlow::PARALLEL->value)
);
try {
$this->validateHelper->canRequestSign($this->userSession->getUser());
$this->initialState->provideInitialState('can_request_sign', true);
} catch (LibresignException) {
$this->initialState->provideInitialState('can_request_sign', false);
}
}
}