Do not fail displaying notification when workflow has been deleted

This commit is contained in:
Julien Fastré 2024-11-12 13:57:20 +01:00
parent 3ec0d26001
commit c3cc6c8353
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
3 changed files with 20 additions and 11 deletions

View File

@ -1,11 +1,15 @@
<h2> {% if handler is not null %}
{{ 'workflow_'|trans }} <h2>
</h2> {{ 'workflow_'|trans }}
</h2>
<div class="item-row col" style="display: block;"> <div class="item-row col" style="display: block;">
{% include handler.template(entity_workflow) with handler.templateData(entity_workflow)|merge({ {% include handler.template(entity_workflow) with handler.templateData(entity_workflow)|merge({
'description': true, 'description': true,
'breadcrumb': true, 'breadcrumb': true,
'add_classes': '' 'add_classes': ''
}) %} }) %}
</div> </div>
{% else %}
<h2>{{ 'workflow.deleted_title'|trans }}</h2>
{% endif %}

View File

@ -33,7 +33,7 @@ class WorkflowNotificationHandler implements NotificationHandlerInterface
return [ return [
'entity_workflow' => $entityWorkflow, 'entity_workflow' => $entityWorkflow,
'handler' => $this->entityWorkflowManager->getHandler($entityWorkflow), 'handler' => null !== $entityWorkflow ? $this->entityWorkflowManager->getHandler($entityWorkflow): null,
'notificationCc' => $this->isNotificationCc($notification), 'notificationCc' => $this->isNotificationCc($notification),
]; ];
} }
@ -45,6 +45,10 @@ class WorkflowNotificationHandler implements NotificationHandlerInterface
if (EntityWorkflow::class === $notification->getRelatedEntityClass()) { if (EntityWorkflow::class === $notification->getRelatedEntityClass()) {
$relatedEntity = $this->entityWorkflowRepository->findOneBy(['id' => $notification->getRelatedEntityId()]); $relatedEntity = $this->entityWorkflowRepository->findOneBy(['id' => $notification->getRelatedEntityId()]);
if (null === $relatedEntity) {
return false;
}
if ($relatedEntity->getCurrentStepCreatedBy() !== $this->security->getUser()) { if ($relatedEntity->getCurrentStepCreatedBy() !== $this->security->getUser()) {
$notificationCc = true; $notificationCc = true;
} }

View File

@ -568,6 +568,7 @@ workflow:
transition_destinee_emails_help: Le lien sécurisé sera envoyé à chaque adresse indiquée transition_destinee_emails_help: Le lien sécurisé sera envoyé à chaque adresse indiquée
sent_through_secured_link: Envoi par lien sécurisé sent_through_secured_link: Envoi par lien sécurisé
public_views_by_ip: Visualisation par adresse IP public_views_by_ip: Visualisation par adresse IP
deleted_title: Workflow supprimé
public_link: public_link:
expired_link_title: Lien expiré expired_link_title: Lien expiré