Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| LoadAdditionalListener | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| handle | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | /** |
| 5 | * SPDX-FileCopyrightText: 2024 LibreCode coop and contributors |
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | */ |
| 8 | |
| 9 | namespace OCA\Libresign\Listener; |
| 10 | |
| 11 | use OCA\Libresign\AppInfo\Application; |
| 12 | use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory; |
| 13 | use OCP\App\IAppManager; |
| 14 | use OCP\EventDispatcher\Event; |
| 15 | use OCP\EventDispatcher\IEventListener; |
| 16 | use OCP\Util; |
| 17 | |
| 18 | /** |
| 19 | * @template-implements IEventListener<Event> |
| 20 | */ |
| 21 | class LoadAdditionalListener implements IEventListener { |
| 22 | private const FILES_LOAD_ADDITIONAL_SCRIPTS_EVENT = 'OCA\\Files\\Event\\LoadAdditionalScriptsEvent'; |
| 23 | |
| 24 | public function __construct( |
| 25 | private IAppManager $appManager, |
| 26 | private CertificateEngineFactory $certificateEngineFactory, |
| 27 | ) { |
| 28 | } |
| 29 | #[\Override] |
| 30 | public function handle(Event $event): void { |
| 31 | if (!is_a($event, self::FILES_LOAD_ADDITIONAL_SCRIPTS_EVENT)) { |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | if (!$this->appManager->isEnabledForUser('libresign')) { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | if (!$this->certificateEngineFactory->getEngine()->isSetupOk()) { |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | if (class_exists('\OCA\Files\App')) { |
| 44 | Util::addInitScript(Application::APP_ID, 'libresign-init'); |
| 45 | } |
| 46 | } |
| 47 | } |