From a524eb21198275b3c95a9b59eb787571eaaaac01 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea <clau.cristea@gmail.com> Date: Sun, 18 Aug 2024 13:04:17 +0300 Subject: [PATCH] ISAICP-9013: Fix the ID redirector. --- .../joinup_core/src/Controller/IdRedirect.php | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/web/modules/custom/joinup_core/src/Controller/IdRedirect.php b/web/modules/custom/joinup_core/src/Controller/IdRedirect.php index 0bf944823c..4ac37e7878 100644 --- a/web/modules/custom/joinup_core/src/Controller/IdRedirect.php +++ b/web/modules/custom/joinup_core/src/Controller/IdRedirect.php @@ -5,8 +5,8 @@ namespace Drupal\joinup_core\Controller; use Drupal\Core\Controller\ControllerBase; -use Drupal\joinup_distribution\Entity\Distribution; -use Drupal\joinup_licence\Entity\Licence; +use Drupal\joinup_rdf\Entity\RdfSyncEntityInterface; +use Drupal\joinup_solution\Entity\SolutionInterface; use Drupal\rdf_sync\RdfSyncMapper; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -56,21 +56,16 @@ public function redirectToRdfEntity(string $namespace, string $uuid): RedirectRe $uuid = urldecode($uuid); $id = "http://data.europa.eu/$namespace/$uuid"; - if ($entity_type_id === 'taxonomy_term') { - if (!$term = $this->mapper->getEntityByUri($id)) { - return $this->redirect('joinup_core.not_found'); - } - $id = $term->id(); - } + // @todo This a temporary solution during conversion of RDF entities to // nodes. Convert to a stable solution in ISAICP-8376. - elseif ($licence = Licence::loadByUri($id)) { - $entity_type_id = 'node'; - $id = $licence->id(); - } - elseif ($distribution = Distribution::loadByUri($id)) { - $entity_type_id = 'node'; - $id = $distribution->id(); + if ($entity = $this->mapper->getEntityByUri($id)) { + // @todo Remove the solution stub exception in ISAICP-8572. + if (!$entity instanceof SolutionInterface) { + assert($entity instanceof RdfSyncEntityInterface); + $entity_type_id = $entity->getEntityTypeId(); + $id = $entity->id(); + } } return $this->redirect("entity.$entity_type_id.canonical", [ -- GitLab