Skip to content

Commit

Permalink
IBX-6312: View matcher ParentContentType should not throw execption i…
Browse files Browse the repository at this point in the history
…f parent is not available
  • Loading branch information
vidarl committed Aug 14, 2023
1 parent 20bebf9 commit db0db7e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ public function match(View $view)
if (!$view instanceof LocationValueView) {
return false;
}
$parent = $this->loadParentLocation(
$view->getLocation()->parentLocationId
);
try {
$parent = $this->loadParentLocation(
$view->getLocation()->parentLocationId
);
} catch (\eZ\Publish\API\Repository\Exceptions\NotFoundException $e) {
return false;
}

return isset($this->values[$parent->getContentInfo()->contentTypeId]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ class ParentContentType extends MultipleValued
*/
public function matchLocation(APILocation $location)
{
$parentContentType = $this->repository->sudo(
static function (Repository $repository) use ($location) {
$parent = $repository->getLocationService()->loadLocation($location->parentLocationId);
try {
$parentContentType = $this->repository->sudo(
static function (Repository $repository) use ($location) {
$parent = $repository->getLocationService()->loadLocation($location->parentLocationId);

return $repository
->getContentTypeService()
->loadContentType($parent->getContentInfo()->contentTypeId);
}
);
return $repository
->getContentTypeService()
->loadContentType($parent->getContentInfo()->contentTypeId);
}
);
} catch (\eZ\Publish\API\Repository\Exceptions\NotFoundException $e) {
return false;
}

return isset($this->values[$parentContentType->identifier]);
}
Expand Down

0 comments on commit db0db7e

Please sign in to comment.