/**
  * @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())));
         }
     }
 }
 /**
  * Action for activating a package
  *
  * @param string $packageKey The package key of the package to create
  * @return string
  */
 public function activateAction($packageKey)
 {
     if ($packageKey === '') {
         return $this->helpAction();
     }
     if ($this->packageManager->isPackageActive($packageKey)) {
         return 'Package "' . $packageKey . '" is already active.' . PHP_EOL;
     }
     $this->packageManager->activatePackage($packageKey);
     return 'Package "' . $packageKey . '" activated.' . PHP_EOL;
 }
 /**
  * @param string $packageKey
  * @return \TYPO3\FLOW3\Error\Error|\TYPO3\FLOW3\Error\Message
  */
 protected function activatePackage($packageKey)
 {
     try {
         $this->packageManager->activatePackage($packageKey);
         $this->doctrineService->updateSchema();
         $message = new \TYPO3\FLOW3\Error\Message('The package ' . $packageKey . ' is activated', 1343231680);
     } catch (\TYPO3\FLOW3\Package\Exception\UnknownPackageException $exception) {
         $message = new \TYPO3\FLOW3\Error\Error('The package ' . $packageKey . ' is not present and can not be activated', 1343231681);
     }
     return $message;
 }
 /**
  * Activate an available package
  *
  * This command activates an existing, but currently inactive package.
  *
  * @FLOW3\FlushesCaches
  * @param string $packageKey The package key of the package to create
  * @return string
  * @see typo3.flow3:package:deactivate
  */
 public function activateCommand($packageKey)
 {
     if ($this->packageManager->isPackageActive($packageKey)) {
         $this->outputLine('Package "%s" is already active.', array($packageKey));
         $this->quit(1);
     }
     $this->packageManager->activatePackage($packageKey);
     $this->outputLine('Activated package "%s".', array($packageKey));
     Scripts::executeCommand('typo3.flow3:cache:flush', $this->settings, FALSE);
     $this->sendAndExit(0);
 }