public function embedLocation($locationId, $viewType, $layout = false, array $params = array())
{
trigger_error("ViewController::embedLocation() is deprecated since kernel 6.0.0, and will be removed in the future.\n" . 'Use ViewController::viewAction() instead.', E_USER_DEPRECATED);
$this->performAccessChecks();
$response = $this->buildResponse();
try {
/** @var \eZ\Publish\API\Repository\Values\Content\Location $location */
$location = $this->getRepository()->sudo(function (Repository $repository) use($locationId) {
return $repository->getLocationService()->loadLocation($locationId);
});
if ($location->invisible) {
throw new NotFoundHttpException("Location #{$locationId} cannot be displayed as it is flagged as invisible.");
}
// Check both 'content/read' and 'content/view_embed'.
if (!$this->authorizationChecker->isGranted(new AuthorizationAttribute('content', 'read', array('valueObject' => $location->contentInfo, 'targets' => $location))) && !$this->authorizationChecker->isGranted(new AuthorizationAttribute('content', 'view_embed', array('valueObject' => $location->contentInfo, 'targets' => $location)))) {
throw new AccessDeniedException();
}
if ($response->isNotModified($this->getRequest())) {
return $response;
}
$response->headers->set('X-Location-Id', $locationId);
$response->setContent($this->renderLocation($location, $viewType, $layout, $params));
return $response;
} catch (UnauthorizedException $e) {
throw new AccessDeniedException();
} catch (NotFoundException $e) {
throw new NotFoundHttpException($e->getMessage(), $e);
} catch (Exception $e) {
return $this->handleViewException($response, $params, $e, $viewType, null, $locationId);
}
}