public function viewContent($contentId, $viewType, $layout = false, array $params = array())
{
trigger_error("ViewController::viewContent() is deprecated since kernel 6.0.0, and will be removed in the future.\n" . 'Use ViewController::viewAction() instead.', E_USER_DEPRECATED);
if ($viewType === 'embed') {
return $this->embedContent($contentId, $viewType, $layout, $params);
}
$this->performAccessChecks();
$response = $this->buildResponse();
try {
$content = $this->getRepository()->getContentService()->loadContent($contentId);
if ($response->isNotModified($this->getRequest())) {
return $response;
}
if (!isset($params['location']) && !isset($params['locationId'])) {
$params['location'] = $this->getRepository()->getLocationService()->loadLocation($content->contentInfo->mainLocationId);
}
$response->headers->set('X-Location-Id', $content->contentInfo->mainLocationId);
$response->setContent($this->renderContent($content, $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, $contentId);
}
}