public function onConfigScopeChange(ScopeChangeEvent $event) { $siteAccess = $event->getSiteAccess(); $this->configResolver->setDefaultScope($siteAccess->name); if ($this->viewManager instanceof SiteAccessAware) { $this->viewManager->setSiteAccess($siteAccess); } }
/** * 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)); } } }
public function onConfigScopeChange(ScopeChangeEvent $event) { $siteAccess = $event->getSiteAccess(); $this->configResolver->setDefaultScope($siteAccess->name); if ($this->viewManager instanceof SiteAccessAware) { $this->viewManager->setSiteAccess($siteAccess); } // Ensure to reset services that need to be. foreach ($this->resettableServiceIds as $serviceId) { $this->container->set($serviceId, null); } // Force dynamic settings services to synchronize. // This will trigger services depending on dynamic settings to update if they use setter injection. foreach ($this->dynamicSettingsServiceIds as $fakeServiceId) { $this->container->set($fakeServiceId, null); $this->container->set($fakeServiceId, $this->container->get($fakeServiceId)); } }
/** * Creates the content to be returned when viewing a Content * * @param Content $content * @param string $viewType * @param boolean $layout * @param array $params */ protected function renderContent($content, $viewType, $layout = false, array $params = array()) { return $this->viewManager->renderContent($content, $viewType, $params + array('noLayout' => !$layout)); }