Skip to content

Commit 1d97292

Browse files
authored
Merge pull request #6100 from LibreSign/refactor/organize-enums-in-dedicated-folder
refactor: organize enums in dedicated folder
2 parents e5d703c + 3a55587 commit 1d97292

11 files changed

Lines changed: 21 additions & 17 deletions

lib/Controller/AdminController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,15 +908,15 @@ public function footerTemplatePreviewPdf(string $template = '', int $width = 595
908908
#[ApiRoute(verb: 'POST', url: '/api/{apiVersion}/admin/signature-flow/config', requirements: ['apiVersion' => '(v1)'])]
909909
public function setSignatureFlowConfig(string $mode): DataResponse {
910910
try {
911-
$signatureFlow = \OCA\Libresign\Service\SignatureFlow::from($mode);
911+
$signatureFlow = \OCA\Libresign\Enum\SignatureFlow::from($mode);
912912
} catch (\ValueError) {
913913
return new DataResponse([
914914
'error' => $this->l10n->t('Invalid signature flow mode. Use "parallel" or "ordered_numeric".'),
915915
], Http::STATUS_BAD_REQUEST);
916916
}
917917

918918
try {
919-
if ($signatureFlow === \OCA\Libresign\Service\SignatureFlow::PARALLEL) {
919+
if ($signatureFlow === \OCA\Libresign\Enum\SignatureFlow::PARALLEL) {
920920
$this->appConfig->deleteKey(Application::APP_ID, 'signature_flow');
921921
} else {
922922
$this->appConfig->setValueString(

lib/Controller/PageController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function index(): TemplateResponse {
9595

9696
$this->provideSignerSignatues();
9797
$this->initialState->provideInitialState('identify_methods', $this->identifyMethodService->getIdentifyMethodsSettings());
98-
$this->initialState->provideInitialState('signature_flow', $this->appConfig->getValueString(Application::APP_ID, 'signature_flow', \OCA\Libresign\Service\SignatureFlow::PARALLEL->value));
98+
$this->initialState->provideInitialState('signature_flow', $this->appConfig->getValueString(Application::APP_ID, 'signature_flow', \OCA\Libresign\Enum\SignatureFlow::PARALLEL->value));
9999
$this->initialState->provideInitialState('legal_information', $this->appConfig->getValueString(Application::APP_ID, 'legal_information'));
100100

101101
Util::addScript(Application::APP_ID, 'libresign-main');

lib/Db/SignRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace OCA\Libresign\Db;
1010

11+
use OCA\Libresign\Enum\SignRequestStatus;
1112
use OCP\AppFramework\Db\Entity;
1213
use OCP\DB\Types;
1314

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22

33
declare(strict_types=1);
4+
45
/**
56
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
67
* SPDX-License-Identifier: AGPL-3.0-or-later
78
*/
89

9-
namespace OCA\Libresign\Db;
10+
namespace OCA\Libresign\Enum;
1011

1112
enum SignRequestStatus: int {
1213
case DRAFT = 0;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22

33
declare(strict_types=1);
4+
45
/**
56
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
67
* SPDX-License-Identifier: AGPL-3.0-or-later
78
*/
89

9-
namespace OCA\Libresign\Service;
10+
namespace OCA\Libresign\Enum;
1011

1112
/**
1213
* Signature flow modes

lib/Files/TemplateLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function handle(Event $event): void {
6060

6161
$this->initialState->provideInitialState(
6262
'signature_flow',
63-
$this->appConfig->getValueString(Application::APP_ID, 'signature_flow', \OCA\Libresign\Service\SignatureFlow::PARALLEL->value)
63+
$this->appConfig->getValueString(Application::APP_ID, 'signature_flow', \OCA\Libresign\Enum\SignatureFlow::PARALLEL->value)
6464
);
6565

6666
try {

lib/Helper/ValidateHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,14 @@ private function validateSignerStatus(string $uuid): void {
720720
$signRequest = $this->signRequestMapper->getByUuid($uuid);
721721
$status = $signRequest->getStatusEnum();
722722

723-
if ($status === \OCA\Libresign\Db\SignRequestStatus::DRAFT) {
723+
if ($status === \OCA\Libresign\Enum\SignRequestStatus::DRAFT) {
724724
throw new LibresignException(json_encode([
725725
'action' => JSActions::ACTION_DO_NOTHING,
726726
'errors' => [['message' => $this->l10n->t('You are not allowed to sign this document yet')]],
727727
]));
728728
}
729729

730-
if ($status === \OCA\Libresign\Db\SignRequestStatus::SIGNED) {
730+
if ($status === \OCA\Libresign\Enum\SignRequestStatus::SIGNED) {
731731
throw new LibresignException(json_encode([
732732
'action' => JSActions::ACTION_DO_NOTHING,
733733
'errors' => [['message' => $this->l10n->t('Document already signed')]],

lib/Service/RequestSignatureService.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,14 @@ private function associateToSigner(
267267
$isNewSignRequest = !$signRequest->getId();
268268
$currentStatus = $signRequest->getStatusEnum();
269269

270-
if ($isNewSignRequest || $currentStatus === \OCA\Libresign\Db\SignRequestStatus::DRAFT) {
270+
if ($isNewSignRequest || $currentStatus === \OCA\Libresign\Enum\SignRequestStatus::DRAFT) {
271271
$initialStatus = $this->determineInitialStatus($signingOrder);
272272
$signRequest->setStatusEnum($initialStatus);
273273
}
274274

275275
$this->saveSignRequest($signRequest);
276276

277-
$shouldNotify = $notify && $signRequest->getStatusEnum() === \OCA\Libresign\Db\SignRequestStatus::ABLE_TO_SIGN;
277+
$shouldNotify = $notify && $signRequest->getStatusEnum() === \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN;
278278

279279
foreach ($identifyMethodsIncances as $identifyMethod) {
280280
$identifyMethod->getEntity()->setSignRequestId($signRequest->getId());
@@ -284,14 +284,14 @@ private function associateToSigner(
284284
return $signRequest;
285285
}
286286

287-
private function determineInitialStatus(int $signingOrder): \OCA\Libresign\Db\SignRequestStatus {
287+
private function determineInitialStatus(int $signingOrder): \OCA\Libresign\Enum\SignRequestStatus {
288288
if (!$this->sequentialSigningService->isOrderedNumericFlow()) {
289-
return \OCA\Libresign\Db\SignRequestStatus::ABLE_TO_SIGN;
289+
return \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN;
290290
}
291291

292292
return $signingOrder === 1
293-
? \OCA\Libresign\Db\SignRequestStatus::ABLE_TO_SIGN
294-
: \OCA\Libresign\Db\SignRequestStatus::DRAFT;
293+
? \OCA\Libresign\Enum\SignRequestStatus::ABLE_TO_SIGN
294+
: \OCA\Libresign\Enum\SignRequestStatus::DRAFT;
295295
}
296296

297297
/**

lib/Service/SequentialSigningService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
use OCA\Libresign\AppInfo\Application;
1212
use OCA\Libresign\Db\SignRequestMapper;
13-
use OCA\Libresign\Db\SignRequestStatus;
13+
use OCA\Libresign\Enum\SignatureFlow;
14+
use OCA\Libresign\Enum\SignRequestStatus;
1415
use OCP\IAppConfig;
1516

1617
class SequentialSigningService {

lib/Service/SignFileService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ protected function updateSignRequest(string $hash): void {
376376
$lastSignedDate = $this->getEngine()->getLastSignedDate();
377377
$this->signRequest->setSigned($lastSignedDate);
378378
$this->signRequest->setSignedHash($hash);
379-
$this->signRequest->setStatusEnum(\OCA\Libresign\Db\SignRequestStatus::SIGNED);
379+
$this->signRequest->setStatusEnum(\OCA\Libresign\Enum\SignRequestStatus::SIGNED);
380380

381381
$this->signRequestMapper->update($this->signRequest);
382382

0 commit comments

Comments
 (0)