Added links to part_lists on part info page.

This commit is contained in:
Jan Böhmer 2019-09-08 16:20:53 +02:00
parent 2040178460
commit 429a4ebd17
5 changed files with 76 additions and 33 deletions

View file

@ -77,9 +77,19 @@ class EntityURLGenerator
{
$class = get_class($entity);
//Check if we have an mapping for the given class
//Check if we have an direct mapping for the given class
if (!array_key_exists($class, $map)) {
throw new EntityNotSupported('The given entity is not supported yet!');
//Check if we need to check inheritance by looping through our map
foreach ($map as $key => $value) {
if (is_a($entity, $key)) {
return $map[$key];
}
}
throw new EntityNotSupported(sprintf(
'The given entity is not supported yet! Passed class type: %s',
get_class($entity)
));
}
return $map[$class];
@ -144,7 +154,10 @@ class EntityURLGenerator
}
//Otherwise throw an error
throw new EntityNotSupported('The given entity is not supported yet!');
throw new EntityNotSupported(sprintf(
'The given entity is not supported yet! Passed class type: %s',
get_class($entity)
));
}
/**