Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| RemovalChanges | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| track | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| activated | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | /** |
| 5 | * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | */ |
| 8 | |
| 9 | namespace OCA\Libresign\Service\SignerRemoval; |
| 10 | |
| 11 | use OCA\Libresign\Db\File; |
| 12 | use OCA\Libresign\Db\SignRequest; |
| 13 | use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod; |
| 14 | |
| 15 | /** |
| 16 | * Tracks records touched by a removal, including when a transaction fails. |
| 17 | * Cache invalidation and notifications must not run inside the transaction. |
| 18 | */ |
| 19 | final class RemovalChanges { |
| 20 | public ?File $file = null; |
| 21 | public ?SignRequest $signRequest = null; |
| 22 | /** @var array<string, array<IIdentifyMethod>> */ |
| 23 | public array $identifyMethods = []; |
| 24 | /** @var array<int, File> */ |
| 25 | public array $files = []; |
| 26 | /** @var array<int, SignRequest> */ |
| 27 | public array $signRequests = []; |
| 28 | /** @var list<SignRequest> */ |
| 29 | public array $activatedSigners = []; |
| 30 | |
| 31 | /** @param list<SignRequest> $signers */ |
| 32 | public function track(File $file, array $signers): void { |
| 33 | $this->files[$file->getId()] = $file; |
| 34 | // Activation can update some of these records before a later write fails. |
| 35 | // Invalidate them all even when that activation never returns its result. |
| 36 | foreach ($signers as $signer) { |
| 37 | $this->signRequests[$signer->getId()] = $signer; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | public function activated(SignRequest $signRequest): void { |
| 42 | $this->signRequests[$signRequest->getId()] = $signRequest; |
| 43 | $this->activatedSigners[] = $signRequest; |
| 44 | } |
| 45 | } |