Example #1
0
 /**
  * @param \TYPO3\Form\Core\Model\FinisherContext $finisherContext
  * @return void
  * @throws \TYPO3\Setup\Exception
  */
 public function importSite(\TYPO3\Form\Core\Model\FinisherContext $finisherContext)
 {
     $formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues();
     if (isset($formValues['prune']) && intval($formValues['prune']) === 1) {
         $this->nodeRepository->removeAll();
         $this->workspaceRepository->removeAll();
         $this->domainRepository->removeAll();
         $this->siteRepository->removeAll();
         $this->persistenceManager->persistAll();
     }
     if (!empty($formValues['packageKey'])) {
         if ($this->packageManager->isPackageAvailable($formValues['packageKey'])) {
             throw new \TYPO3\Setup\Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486);
         }
         $packageKey = $formValues['packageKey'];
         $siteName = $formValues['packageKey'];
         $this->packageManager->createPackage($packageKey, NULL, Files::getUnixStylePath(Files::concatenatePaths(array(FLOW3_PATH_PACKAGES, 'Sites'))));
         $this->generatorService->generateSitesXml($packageKey, $siteName);
         $this->generatorService->generateSitesTypoScript($packageKey, $siteName);
         $this->generatorService->generateSitesTemplate($packageKey, $siteName);
         $this->packageManager->activatePackage($packageKey);
     } else {
         $packageKey = $formValues['site'];
     }
     if ($packageKey !== '') {
         try {
             $contentContext = new \TYPO3\TYPO3\Domain\Service\ContentContext('live');
             $this->nodeRepository->setContext($contentContext);
             $this->siteImportService->importFromPackage($packageKey);
         } catch (\Exception $exception) {
             $finisherContext->cancel();
             $this->flashMessageContainer->addMessage(new \TYPO3\FLOW3\Error\Error(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage())));
         }
     }
 }
Example #2
0
 /**
  * Initializes the context after all dependencies have been injected.
  *
  * @return void
  */
 public function initializeObject()
 {
     $this->locale = new Locale('mul_ZZ');
     $activeRequestHandler = $this->bootstrap->getActiveRequestHandler();
     if ($activeRequestHandler instanceof \TYPO3\FLOW3\Http\HttpRequestHandlerInterface) {
         $matchingDomains = $this->domainRepository->findByHost($activeRequestHandler->getHttpRequest()->getUri()->getHost());
         if (count($matchingDomains) > 0) {
             $this->currentDomain = $matchingDomains[0];
             $this->currentSite = $matchingDomains[0]->getSite();
         } else {
             $this->currentSite = $this->siteRepository->findFirst();
         }
     } else {
         $this->currentSite = $this->siteRepository->findFirst();
     }
 }
 /**
  * Delete a domain record
  *
  * @param string $hostPattern The host pattern of the domain to remove
  * @return void
  */
 public function deleteCommand($hostPattern)
 {
     $domain = $this->domainRepository->findOneByHostPattern($hostPattern);
     if (!$domain instanceof Domain) {
         $this->outputLine('Domain is not found');
         $this->quit(1);
     }
     $this->domainRepository->remove($domain);
     $this->outputLine('Domain deleted');
 }
 /**
  * Remove all content and related data - for now. In the future we need some more sophisticated cleanup.
  *
  * @param boolean $confirmation
  * @return void
  */
 public function pruneCommand($confirmation = FALSE)
 {
     if ($confirmation === FALSE) {
         $this->outputLine('Please confirm that you really want to remove all sites and content from the database.');
         $this->outputLine('');
         $this->outputLine('Syntax:');
         $this->outputLine('  ./flow3 site:prune --confirmation TRUE');
         $this->quit(1);
     }
     $this->nodeRepository->removeAll();
     $this->workspaceRepository->removeAll();
     $this->domainRepository->removeAll();
     $this->siteRepository->removeAll();
     $this->outputLine('All sites and content have been removed.');
 }