From 963cf132fd952ab0a853848b61fe77f1351f2619 Mon Sep 17 00:00:00 2001 From: Rainer Friederich Date: Wed, 11 Oct 2023 15:08:49 +0200 Subject: [PATCH 1/2] handle exception on generating the url --- modules/next/src/Event/EntityActionEvent.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/next/src/Event/EntityActionEvent.php b/modules/next/src/Event/EntityActionEvent.php index 4fddddf3..35eaa8f1 100644 --- a/modules/next/src/Event/EntityActionEvent.php +++ b/modules/next/src/Event/EntityActionEvent.php @@ -75,8 +75,11 @@ public static function createFromEntity(EntityInterface $entity, string $action) $next_entity_type_manager = \Drupal::service('next.entity_type.manager'); $sites = $next_entity_type_manager->getSitesForEntity($entity); - $url = $entity->hasLinkTemplate('canonical') ? $entity->toUrl()->toString(TRUE)->getGeneratedUrl() : NULL; - + try { + $url = $entity->hasLinkTemplate('canonical') ? $entity->toUrl()->toString(TRUE)->getGeneratedUrl() : NULL; + } catch (\Exception $e) { + $url = NULL; + } return new static($entity, $action, $sites, $url); } From 82fb82adf702fd6ef754dc7269781244c6266be5 Mon Sep 17 00:00:00 2001 From: Rainer Friederich Date: Thu, 22 Feb 2024 13:24:22 +0100 Subject: [PATCH 2/2] drupal coding standards --- modules/next/src/Event/EntityActionEvent.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/next/src/Event/EntityActionEvent.php b/modules/next/src/Event/EntityActionEvent.php index 35eaa8f1..f900f4c1 100644 --- a/modules/next/src/Event/EntityActionEvent.php +++ b/modules/next/src/Event/EntityActionEvent.php @@ -77,7 +77,8 @@ public static function createFromEntity(EntityInterface $entity, string $action) $sites = $next_entity_type_manager->getSitesForEntity($entity); try { $url = $entity->hasLinkTemplate('canonical') ? $entity->toUrl()->toString(TRUE)->getGeneratedUrl() : NULL; - } catch (\Exception $e) { + } + catch (\Exception $e) { $url = NULL; } return new static($entity, $action, $sites, $url);