Skip to content
Snippets Groups Projects
Commit 36878d4b authored by Claudiu Cristea's avatar Claudiu Cristea
Browse files

Merge branch 'ISAICP-9022' into 'develop'

ISAICP-9022: Fix redirects for paths corresponding to persistent URIs without a matching uuid.

See merge request digit/digit-joinup-dev!1564
parents e1028164 52e39623
No related branches found
No related tags found
1 merge request!183Release v1.112.0
......@@ -108,3 +108,9 @@ Feature:
Then I should see the heading "Dream Domain"
And I should see "You're safe from pain in the dream domain."
And the url should match "/taxonomy/term/\d+"
Scenario: Test paths corresponding to EU persistent URI namespaces without a matching uuid
Given I am on "data/dr8/non-existing-uiid"
Then I should see the heading "Page not found"
When I am on "data/w21/non-existing-uiid"
Then I should see the heading "Page not found"
......@@ -5,6 +5,7 @@
namespace Drupal\joinup_core\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\joinup_group\Entity\GroupInterface;
use Drupal\joinup_rdf\Entity\RdfSyncEntityInterface;
use Drupal\joinup_solution\Entity\SolutionInterface;
use Drupal\rdf_sync\RdfSyncMapper;
......@@ -59,18 +60,25 @@ public function redirectToRdfEntity(string $namespace, string $uuid): RedirectRe
// @todo This a temporary solution during conversion of RDF entities to
// nodes. Convert to a stable solution in ISAICP-8376.
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();
}
if (
$entity_type_id === 'rdf_entity' &&
($entity = $this->entityTypeManager()->getStorage('rdf_entity')->load($id)) &&
$entity instanceof GroupInterface
) {
return $this->redirect("entity.rdf_entity.canonical", [
$entity_type_id => $id,
], [], 301);
}
// @todo Remove the second condition, for solution stub exception, in ISAICP-8572.
elseif (($entity = $this->mapper->getEntityByUri($id)) && !$entity instanceof SolutionInterface) {
assert($entity instanceof RdfSyncEntityInterface);
$entity_type_id = $entity->getEntityTypeId();
return $this->redirect("entity.$entity_type_id.canonical", [
$entity_type_id => $entity->id(),
], [], 301);
}
return $this->redirect("entity.$entity_type_id.canonical", [
$entity_type_id => $id,
], [], 301);
return $this->redirect('joinup_core.not_found');
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment