mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-09 13:48:23 +00:00
Signature fixes
This commit is contained in:
@@ -11,9 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Workflow\Messenger;
|
||||
|
||||
use Chill\DocStoreBundle\Exception\StoredObjectManagerException;
|
||||
use Chill\DocStoreBundle\Service\StoredObjectToPdfConverter;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSend;
|
||||
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
|
||||
@@ -25,6 +29,8 @@ final readonly class PostSendExternalMessageHandler implements MessageHandlerInt
|
||||
private EntityWorkflowRepository $entityWorkflowRepository,
|
||||
private MailerInterface $mailer,
|
||||
private EntityWorkflowManager $workflowManager,
|
||||
private StoredObjectToPdfConverter $storedObjectToPdfConverter,
|
||||
private LoggerInterface $logger,
|
||||
) {}
|
||||
|
||||
public function __invoke(PostSendExternalMessage $message): void
|
||||
@@ -35,11 +41,34 @@ final readonly class PostSendExternalMessageHandler implements MessageHandlerInt
|
||||
throw new UnrecoverableMessageHandlingException(sprintf('Entity workflow with id %d not found', $message->entityWorkflowId));
|
||||
}
|
||||
|
||||
$this->convertToPdf($entityWorkflow, $message->lang);
|
||||
|
||||
foreach ($entityWorkflow->getCurrentStep()->getSends() as $send) {
|
||||
$this->sendEmailToDestinee($send, $message);
|
||||
}
|
||||
}
|
||||
|
||||
private function convertToPdf(EntityWorkflow $entityWorkflow, string $locale): void
|
||||
{
|
||||
foreach ($entityWorkflow->getAttachments() as $attachment) {
|
||||
try {
|
||||
$this->storedObjectToPdfConverter->addConvertedVersion($attachment->getProxyStoredObject(), $locale);
|
||||
} catch (StoredObjectManagerException $e) {
|
||||
$this->logger->error('Error converting attachment to PDF', ['backtrace' => $e->getTraceAsString(), 'attachment_id' => $attachment->getId()]);
|
||||
}
|
||||
}
|
||||
|
||||
$storedObject = $this->workflowManager->getAssociatedStoredObject($entityWorkflow);
|
||||
|
||||
if (null !== $storedObject) {
|
||||
try {
|
||||
$this->storedObjectToPdfConverter->addConvertedVersion($storedObject, $locale);
|
||||
} catch (StoredObjectManagerException $e) {
|
||||
$this->logger->error('Error converting stored object to PDF', ['backtrace' => $e->getTraceAsString(), 'stored_object_id' => $storedObject->getId(), 'workflow_id' => $entityWorkflow->getId()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function sendEmailToDestinee(EntityWorkflowSend $send, PostSendExternalMessage $message): void
|
||||
{
|
||||
$entityWorkflow = $send->getEntityWorkflowStep()->getEntityWorkflow();
|
||||
|
||||
Reference in New Issue
Block a user