diff --git a/src/lib/Server/Output/ValueObjectVisitor/RestExecutedView.php b/src/lib/Server/Output/ValueObjectVisitor/RestExecutedView.php index 9ebe3a8e..935e9927 100644 --- a/src/lib/Server/Output/ValueObjectVisitor/RestExecutedView.php +++ b/src/lib/Server/Output/ValueObjectVisitor/RestExecutedView.php @@ -6,6 +6,8 @@ */ namespace EzSystems\EzPlatformRest\Server\Output\ValueObjectVisitor; +use eZ\Publish\API\Repository\Exceptions\NotFoundException; +use eZ\Publish\API\Repository\Exceptions\UnauthorizedException; use eZ\Publish\API\Repository\Values\Content as ApiValues; use EzSystems\EzPlatformRest\Exceptions; use EzSystems\EzPlatformRest\Output\ValueObjectVisitor; @@ -113,9 +115,16 @@ public function visit(Visitor $visitor, Generator $generator, $data) if ($searchHit->valueObject instanceof ApiValues\Content) { /** @var \eZ\Publish\API\Repository\Values\Content\Content $searchHit->valueObject */ $contentInfo = $searchHit->valueObject->contentInfo; + + try { + $mainLocation = $this->locationService->loadLocation($contentInfo->mainLocationId); + } catch (NotFoundException | UnauthorizedException $e) { + $mainLocation = null; + } + $valueObject = new RestContentValue( $contentInfo, - $this->locationService->loadLocation($contentInfo->mainLocationId), + $mainLocation, $searchHit->valueObject, $searchHit->valueObject->getContentType(), $this->contentService->loadRelations($searchHit->valueObject->getVersionInfo())