Block document editing if any signature associated to a workflow is signed

Add a check in `WorkflowStoredObjectPermissionHelper` to block document editing once any signature is signed. Accompanied by new tests to verify this behavior.
This commit is contained in:
2024-09-19 14:24:47 +02:00
parent c4c5c860f0
commit 77d06d756a
2 changed files with 112 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\Service;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSignatureStateEnum;
use Chill\MainBundle\Workflow\EntityWorkflowManager;
use Symfony\Component\Security\Core\Security;
@@ -31,6 +32,16 @@ class WorkflowStoredObjectPermissionHelper
if (!$workflow->getCurrentStep()->getAllDestUser()->contains($currentUser)) {
return false;
}
// as soon as there is one signatured applyied, we are not able to
// edit the document any more
foreach ($workflow->getSteps() as $step) {
foreach ($step->getSignatures() as $signature) {
if (EntityWorkflowSignatureStateEnum::SIGNED === $signature->getState()) {
return false;
}
}
}
}
return true;