Create CancelStaleWorkflow message and handler

This commit is contained in:
Julie Lenaerts 2024-08-08 17:00:27 +02:00 committed by Julien Fastré
parent bf056046ab
commit 860ae5cedf
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace Chill\MainBundle\Service\Workflow;
class CancelStaleWorkflow
{
public function __construct(public array $workflowIds)
{
}
public function getWorkflowIds(): array
{
return $this->workflowIds;
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace Chill\MainBundle\Service\Workflow;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
class CancelStaleWorkflowHandler implements MessageHandlerInterface
{
public function __construct(private readonly EntityWorkflowRepository $workflowRepository, private EntityManagerInterface $em, private LoggerInterface $logger)
{
}
public function __invoke(CancelStaleWorkflow $message): void
{
$workflowIds = $message->getWorkflowIds();
foreach ($workflowIds as $workflowId) {
$workflow = $this->workflowRepository->find($workflowId);
$steps = $workflow->getSteps();
}
}
}