/**
  * 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.');
 }
 /**
  * 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.');
 }
Ejemplo n.º 3
0
 /**
  * @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;
 }
 /**
  * Create a domain
  *
  * @param Domain $domain Domain to create
  * @Flow\Validate(argumentName="$domain", type="UniqueEntity")
  * @return void
  */
 public function createDomainAction(Domain $domain)
 {
     $this->domainRepository->add($domain);
     $this->addFlashMessage('The domain "%s" has been created.', 'Domain created', Message::SEVERITY_OK, array(htmlspecialchars($domain)), 1412373192);
     $this->unsetLastVisitedNodeAndRedirect('edit', null, null, array('site' => $domain->getSite()));
 }