Refactor PDF signature handling and add signature state changer

Simplified PdfSignedMessageHandler by delegating signature state changes to a new SignatureStepStateChanger class. Added utility method to EntityWorkflowStepSignature for checking pending signatures and created new test cases for the SignatureStepStateChanger.
This commit is contained in:
nobohan
2024-07-18 17:13:47 +02:00
committed by Julien Fastré
parent 00e878892e
commit 1197a46f5f
5 changed files with 276 additions and 10 deletions

View File

@@ -141,6 +141,32 @@ class EntityWorkflowStepSignature implements TrackCreationInterface, TrackUpdate
return EntityWorkflowSignatureStateEnum::SIGNED == $this->getState();
}
public function isPending(): bool
{
return EntityWorkflowSignatureStateEnum::PENDING == $this->getState();
}
/**
* Checks whether all signatures associated with a given workflow step are not pending.
*
* Iterates over each signature in the provided workflow step, and returns false if any signature
* is found to be pending. If all signatures are not pending, returns true.
*
* @param EntityWorkflowStep $step the workflow step whose signatures are to be checked
*
* @return bool true if all signatures are not pending, false otherwise
*/
public static function isAllSignatureNotPendingForStep(EntityWorkflowStep $step): bool
{
foreach ($step->getSignatures() as $signature) {
if ($signature->isPending()) {
return false;
}
}
return true;
}
/**
* @return 'person'|'user'
*/