Skip to content

Commit

Permalink
EZP-31776: Provided 'null' as Location in RestExecutedView if unavail…
Browse files Browse the repository at this point in the history
…able (#53)

Co-authored-by: Bartek Wajda <bartlomiej.wajda@ibexa.co>
  • Loading branch information
Bartek and barw4 authored Aug 26, 2020
1 parent b7094ab commit 64a7a59
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib/Server/Output/ValueObjectVisitor/RestExecutedView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 64a7a59

Please # to comment.