$content and $location will be injected in the selected template.
public renderLocation ( eZ\Publish\API\Repository\Values\Content\Location $location, string $viewType = self::VIEW_TYPE_FULL, array $parameters = [] ) : string | ||
$location | eZ\Publish\API\Repository\Values\Content\Location | |
$viewType | string | Variation of display for your content. Default is 'full'. |
$parameters | array | Parameters to pass to the template called to render the view. By default, it's empty. 'location' and 'content' entries are reserved for the Location (and its Content) that is viewed. |
Результат | string |
/** * Process embed tags for a single tag type (embed or embed-inline) * @param \DOMDocument $xmlDoc * @param $tagName string name of the tag to extract */ protected function processTag(DOMDocument $xmlDoc, $tagName) { /** @var $embed \DOMElement */ foreach ($xmlDoc->getElementsByTagName($tagName) as $embed) { if (!($view = $embed->getAttribute("view"))) { $view = $tagName; } $embedContent = null; $parameters = array("noLayout" => true, "objectParameters" => array()); foreach ($embed->attributes as $attribute) { // We only consider tags in the custom namespace, and skip disallowed names if (!isset($this->excludedAttributes[$attribute->localName])) { $parameters["objectParameters"][$attribute->localName] = $attribute->nodeValue; } } if ($contentId = $embed->getAttribute("object_id")) { /** @var \eZ\Publish\API\Repository\Values\Content\Content $content */ $content = $this->repository->sudo(function (Repository $repository) use($contentId) { return $repository->getContentService()->loadContent($contentId); }); if (!$this->repository->canUser('content', 'read', $content) && !$this->repository->canUser('content', 'view_embed', $content)) { throw new UnauthorizedException('content', 'read'); } // Check published status of the Content if ($content->getVersionInfo()->status !== APIVersionInfo::STATUS_PUBLISHED && !$this->repository->canUser('content', 'versionread', $content)) { throw new UnauthorizedException('content', 'versionread'); } $embedContent = $this->viewManager->renderContent($content, $view, $parameters); } else { if ($locationId = $embed->getAttribute("node_id")) { /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */ $location = $this->repository->sudo(function (Repository $repository) use($locationId) { return $repository->getLocationService()->loadLocation($locationId); }); if (!$this->repository->canUser('content', 'read', $location->getContentInfo(), $location) && !$this->repository->canUser('content', 'view_embed', $location->getContentInfo(), $location)) { throw new UnauthorizedException('content', 'read'); } $embedContent = $this->viewManager->renderLocation($location, $view, $parameters); } } if ($embedContent !== null) { $embed->appendChild($xmlDoc->createCDATASection($embedContent)); } } }
/** * Creates the content to be returned when viewing a Location * * @param Location $location * @param string $viewType * @param boolean $layout * @param array $params */ protected function renderLocation($location, $viewType, $layout = false, array $params = array()) { return $this->viewManager->renderLocation($location, $viewType, $params + array('noLayout' => !$layout)); }