Skip to content
Snippets Groups Projects
Commit 8b50865b authored by Ilias Dimopoulos's avatar Ilias Dimopoulos Committed by Claudiu Cristea
Browse files

ISAICP-9526: Fix some cases where the suffix is empty.

parent 9350f7eb
No related branches found
No related tags found
1 merge request!211Release 2.2.2
......@@ -66,12 +66,16 @@ public function getTargetEntity(string $path): array {
return [NULL, NULL];
}
if (!$entity = $this->getEntity($found['uri'], $found['suffix'])) {
if (!$entity = $this->getEntity($found['uri'], $found['suffix'] ?? '')) {
return [NULL, NULL];
}
// In case we found that the suffix is part of the IRI, then, return an
// empty string as suffix.
if (!isset($found['suffix'])) {
return [$entity, ''];
}
return str_ends_with($entity->getUri(), $found['suffix'])
? [$entity, '']
: [$entity, $found['suffix']];
......@@ -88,7 +92,7 @@ public function getTargetEntity(string $path): array {
* @return \Drupal\joinup_rdf\Entity\RdfSyncEntityInterface|null
* The entity or NULL if the request URL doesn't designate a mapped entity.
*/
protected function getEntity(string $encodedUri, string $suffix): ?RdfSyncEntityInterface {
protected function getEntity(string $encodedUri, string $suffix = ''): ?RdfSyncEntityInterface {
// With the legacy storage, RDF entity IDs were encoded URIs.
$uri = strtr($encodedUri, self::MAP);
......
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