/** * @test */ public function setSiteSetsTheSiteTheDomainIsPointingTo() { $mockSite = $this->getMockBuilder(Site::class)->disableOriginalConstructor()->getMock(); $domain = new Domain(); $domain->setSite($mockSite); $this->assertSame($mockSite, $domain->getSite()); }
/** * Add a domain record * * @param string $siteNodeName The nodeName of the site rootNode, e.g. "neostypo3org" * @param string $hostPattern The host pattern to match on, e.g. "neos.typo3.org" * @return void */ public function addCommand($siteNodeName, $hostPattern) { $site = $this->siteRepository->findOneByNodeName($siteNodeName); if (!$site instanceof Site) { $this->outputLine('No site found with nodeName "%s".', array($siteNodeName)); $this->quit(1); } $domains = $this->domainRepository->findByHostPattern($hostPattern); if ($domains->count() > 0) { $this->outputLine('The host pattern "%s" is not unique.', array($hostPattern)); $this->quit(1); } $domain = new Domain(); $domain->setSite($site); $domain->setHostPattern($hostPattern); $this->domainRepository->add($domain); $this->outputLine('Domain created.'); }
/** * @param string $sitePackage * @param string $siteName * @param string $baseDomain * @return Site */ public function importSiteFromTemplate($sitePackage, $siteName, $baseDomain = '') { if (empty($baseDomain)) { $request = Request::createFromEnvironment(); $baseDomain = $request->getBaseUri()->getHost(); } $siteTemplate = new StandaloneView(); $siteTemplate->setTemplatePathAndFilename(FLOW_PATH_PACKAGES . 'Sites/' . $sitePackage . '/Resources/Private/Templates/Content/Sites.xml'); $siteTemplate->assignMultiple(['siteName' => $siteName, 'siteNodeName' => \TYPO3\TYPO3CR\Utility::renderValidNodeName($siteName), 'packageKey' => $sitePackage]); $generatedSiteImportXmlContent = $siteTemplate->render(); $dataTemporaryPath = $this->environment->getPathToTemporaryDirectory(); $temporarySiteXml = $dataTemporaryPath . uniqid($siteName) . '.xml'; file_put_contents($temporarySiteXml, $generatedSiteImportXmlContent); $site = $this->siteImportService->importFromFile($temporarySiteXml); $domain = new Domain(); $domain->setActive(true); $domain->setSite($site); $domain->setHostPattern(\TYPO3\TYPO3CR\Utility::renderValidNodeName($siteName) . '.' . $baseDomain); $this->domainRepository->add($domain); return $site; }
/** * Add a domain record * * @param string $siteNodeName The nodeName of the site rootNode, e.g. "neostypo3org" * @param string $hostPattern The host pattern to match on, e.g. "neos.typo3.org" * @param string $scheme The scheme for linking (http/https) * @param integer $port The port for linking (0-49151) * @return void */ public function addCommand($siteNodeName, $hostPattern, $scheme = null, $port = null) { $site = $this->siteRepository->findOneByNodeName($siteNodeName); if (!$site instanceof Site) { $this->outputLine('<error>No site found with nodeName "%s".</error>', array($siteNodeName)); $this->quit(1); } $domains = $this->domainRepository->findByHostPattern($hostPattern); if ($domains->count() > 0) { $this->outputLine('<error>The host pattern "%s" is not unique.</error>', array($hostPattern)); $this->quit(1); } $domain = new Domain(); if ($scheme !== null) { $domain->setScheme($scheme); } if ($port !== null) { $domain->setPort($port); } $domain->setSite($site); $domain->setHostPattern($hostPattern); $domainValidator = $this->validatorResolver->getBaseValidatorConjunction(Domain::class); $result = $domainValidator->validate($domain); if ($result->hasErrors()) { foreach ($result->getFlattenedErrors() as $propertyName => $errors) { $firstError = array_pop($errors); $this->outputLine('<error>Validation failed for "' . $propertyName . '": ' . $firstError . '</error>'); $this->quit(1); } } $this->domainRepository->add($domain); $this->outputLine('Domain created.'); }
/** * Creates a new content context based on the given workspace and the NodeData object and additionally takes * the current site and current domain into account. * * @param Workspace $workspace Workspace for the new context * @param array $dimensionValues The dimension values for the new context * @param array $contextProperties Additional pre-defined context properties * @return Context */ protected function createContext(Workspace $workspace, array $dimensionValues, array $contextProperties = array()) { if ($this->currentDomain === false) { $this->currentDomain = $this->domainRepository->findOneByActiveRequest(); } if ($this->currentDomain !== null) { $contextProperties['currentSite'] = $this->currentDomain->getSite(); $contextProperties['currentDomain'] = $this->currentDomain; } else { if ($this->currentSite === false) { $this->currentSite = $this->siteRepository->findFirstOnline(); } $contextProperties['currentSite'] = $this->currentSite; } return parent::createContext($workspace, $dimensionValues, $contextProperties); }
/** * Deactivates a domain * * @param Domain $domain Domain to deactivate * @Flow\IgnoreValidation("$domain") * @return void */ public function deactivateDomainAction(Domain $domain) { $domain->setActive(false); $this->domainRepository->update($domain); $this->addFlashMessage('The domain "%s" has been deactivated.', 'Domain deactivated', Message::SEVERITY_OK, array(htmlspecialchars($domain)), 1412373425); $this->unsetLastVisitedNodeAndRedirect('edit', null, null, array('site' => $domain->getSite())); }
/** * Returns the primary domain, if one has been defined. * * @return Domain The primary domain or NULL * @api */ public function getPrimaryDomain() { return isset($this->primaryDomain) && $this->primaryDomain->getActive() ? $this->primaryDomain : $this->getFirstActiveDomain(); }
/** * Deactivates a domain * * @param Domain $domain Domain to deactivate * @return void */ public function deactivateDomainAction(Domain $domain) { $domain->setActive(FALSE); $this->domainRepository->update($domain); $this->addFlashMessage('The domain "%s" has been deactivated.', 'Domain deactivated', Message::SEVERITY_OK, array($domain->getHostPattern()), 1412373425); $this->unsetLastVisitedNodeAndRedirect('edit', NULL, NULL, array('site' => $domain->getSite())); }