/** * If the imported site is of a legacy schema where the near-root <site> element wasn't * an actual node, the respective site xml is "upgraded" to become of type Shortcut, * get a `title` property being the site's name, and being set to hidden in index. * * @param \SimpleXMLElement $siteXml * @param \TYPO3\Neos\Domain\Model\Site $site * @return void */ protected function upgradeLegacySiteXml(\SimpleXMLElement $siteXml, Site $site) { $siteXml->addAttribute('type', 'TYPO3.Neos:Shortcut'); $siteXml->addAttribute('hiddenInIndex', 'true'); if (property_exists($siteXml->properties, 'title') === false) { $siteXml->properties->addChild('title', $site->getName()); } }
/** * @test */ public function aNameCanBeSetAndRetrievedFromTheSite() { $site = new Site(''); $site->setName('My cool website'); $this->assertSame('My cool website', $site->getName()); }
/** * @param ControllerContext $controllerContext * @param Site $site * @return string * @throws NeosException */ public function createSiteUri(ControllerContext $controllerContext, Site $site) { $primaryDomain = $site->getPrimaryDomain(); if ($primaryDomain === null) { throw new NeosException(sprintf('Cannot link to a site "%s" since it has no active domains.', $site->getName()), 1460443524); } $requestUri = $controllerContext->getRequest()->getHttpRequest()->getUri(); $baseUri = $controllerContext->getRequest()->getHttpRequest()->getBaseUri(); $port = $primaryDomain->getPort() ?: $requestUri->getPort(); return sprintf('%s://%s%s%s', $primaryDomain->getScheme() ?: $requestUri->getScheme(), $primaryDomain->getHostPattern(), $port && !in_array($port, [80, 443], true) ? ':' . $port : '', rtrim($baseUri->getPath(), '/')); }
/** * Export the given $site to the XMLWriter * * @param Site $site * @param string $nodeTypeFilter * @return void */ protected function exportSite(Site $site, $nodeTypeFilter) { /** @var ContentContext $contentContext */ $contentContext = $this->contextFactory->create(array('currentSite' => $site, 'invisibleContentShown' => true, 'inaccessibleContentShown' => true)); $siteNode = $contentContext->getCurrentSiteNode(); $this->xmlWriter->startElement('site'); $this->xmlWriter->writeAttribute('name', $site->getName()); $this->xmlWriter->writeAttribute('state', $site->getState()); $this->xmlWriter->writeAttribute('siteResourcesPackageKey', $site->getSiteResourcesPackageKey()); $this->xmlWriter->writeAttribute('siteNodeName', $siteNode->getName()); $this->nodeExportService->export($siteNode->getPath(), $contentContext->getWorkspaceName(), $this->xmlWriter, false, false, $this->resourcesPath, $nodeTypeFilter); $this->xmlWriter->endElement(); }
/** * @param Site $site * @param string $contentType * @return void */ public function purgeAllVarnishCacheAction(Site $site = NULL, $contentType = NULL) { $domain = $site !== NULL ? $site->getFirstActiveDomain()->getHostPattern() : NULL; $service = new VarnishBanService(); $service->banAll($domain, $contentType); $this->flashMessageContainer->addMessage(new Message(sprintf('All varnish cache cleared for %s%s', $site ? 'site ' . $site->getName() : 'installation', $contentType ? ' with content type "' . $contentType . '"' : ''))); $this->redirect('index'); }