mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-17 15:54:23 +00:00
Introduce MessageBus to handle post-signature operations asynchronously. This ensures that further steps are executed through dispatched messages, improving system scalability and performance. Implement new handlers and messages for the workflow state transitions.
42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Workflow\Messenger;
|
|
|
|
use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepSignatureRepository;
|
|
use Chill\MainBundle\Workflow\SignatureStepStateChanger;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
|
|
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
|
|
|
|
final readonly class PostSignatureStateChangeHandler implements MessageHandlerInterface
|
|
{
|
|
public function __construct(
|
|
private EntityWorkflowStepSignatureRepository $entityWorkflowStepSignatureRepository,
|
|
private SignatureStepStateChanger $signatureStepStateChanger,
|
|
private EntityManagerInterface $entityManager,
|
|
) {}
|
|
|
|
public function __invoke(PostSignatureStateChangeMessage $message): void
|
|
{
|
|
$signature = $this->entityWorkflowStepSignatureRepository->find($message->signatureId);
|
|
|
|
if (null === $signature) {
|
|
throw new UnrecoverableMessageHandlingException('signature not found');
|
|
}
|
|
|
|
$this->signatureStepStateChanger->onPostMark($signature);
|
|
|
|
$this->entityManager->flush();
|
|
$this->entityManager->clear();
|
|
}
|
|
}
|