protected function checkContent($id) { /** @var \eZ\Publish\API\Repository\Values\Content\Content $content */ $content = $this->repository->sudo(function (Repository $repository) use($id) { return $repository->getContentService()->loadContent($id); }); // Check both 'content/read' and 'content/view_embed'. if (!$this->authorizationChecker->isGranted(new AuthorizationAttribute('content', 'read', array('valueObject' => $content))) && !$this->authorizationChecker->isGranted(new AuthorizationAttribute('content', 'view_embed', array('valueObject' => $content)))) { throw new AccessDeniedException(); } // Check that Content is published, since sudo allows loading unpublished content. if ($content->getVersionInfo()->status !== VersionInfo::STATUS_PUBLISHED && !$this->authorizationChecker->isGranted(new AuthorizationAttribute('content', 'versionread', array('valueObject' => $content)))) { throw new AccessDeniedException(); } }