public function setUp()
 {
     parent::setUp();
     $this->markSkippedIfNodeTypesPackageIsNotInstalled();
     $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
     $contentContext = $this->contextFactory->create(array('workspaceName' => 'live'));
     $this->siteImportService = $this->objectManager->get(SiteImportService::class);
     $this->siteExportService = $this->objectManager->get(SiteExportService::class);
     $this->importedSite = $this->siteImportService->importFromFile(__DIR__ . '/' . $this->fixtureFileName, $contentContext);
     $this->persistenceManager->persistAll();
 }
 /**
  * @param FinisherContext $finisherContext
  * @return void
  * @throws Exception
  */
 public function importSite(FinisherContext $finisherContext)
 {
     $formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues();
     if (isset($formValues['prune']) && intval($formValues['prune']) === 1) {
         $this->nodeDataRepository->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 Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486);
         }
         $packageKey = $formValues['packageKey'];
         $siteName = $formValues['siteName'];
         $generatorService = $this->objectManager->get(\Neos\SiteKickstarter\Service\GeneratorService::class);
         $generatorService->generateSitePackage($packageKey, $siteName);
     } elseif (!empty($formValues['site'])) {
         $packageKey = $formValues['site'];
     }
     $this->deactivateOtherSitePackages($packageKey);
     $this->packageManager->activatePackage($packageKey);
     if (!empty($packageKey)) {
         try {
             $contentContext = $this->contextFactory->create(array('workspaceName' => 'live'));
             $this->siteImportService->importFromPackage($packageKey, $contentContext);
         } catch (\Exception $exception) {
             $finisherContext->cancel();
             $this->systemLogger->logException($exception);
             throw new SetupException(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage()), 1351000864);
         }
     }
 }
 /**
  * Import sites content
  *
  * This command allows for importing one or more sites or partial content from an XML source. The format must
  * be identical to that produced by the export command.
  *
  * If a filename is specified, this command expects the corresponding file to contain the XML structure. The
  * filename php://stdin can be used to read from standard input.
  *
  * If a package key is specified, this command expects a Sites.xml file to be located in the private resources
  * directory of the given package (Resources/Private/Content/Sites.xml).
  *
  * @param string $packageKey Package key specifying the package containing the sites content
  * @param string $filename relative path and filename to the XML file containing the sites content
  * @return void
  */
 public function importCommand($packageKey = null, $filename = null)
 {
     $exceedingArguments = $this->request->getExceedingArguments();
     if (isset($exceedingArguments[0]) && $packageKey === null && $filename === null) {
         if (file_exists($exceedingArguments[0])) {
             $filename = $exceedingArguments[0];
         } elseif ($this->packageManager->isPackageAvailable($exceedingArguments[0])) {
             $packageKey = $exceedingArguments[0];
         }
     }
     if ($packageKey === null && $filename === null) {
         $this->outputLine('You have to specify either "--package-key" or "--filename"');
         $this->quit(1);
     }
     $site = null;
     if ($filename !== null) {
         try {
             $site = $this->siteImportService->importFromFile($filename);
         } catch (\Exception $exception) {
             $this->systemLogger->logException($exception);
             $this->outputLine('<error>During the import of the file "%s" an exception occurred: %s, see log for further information.</error>', array($filename, $exception->getMessage()));
             $this->quit(1);
         }
     } else {
         try {
             $site = $this->siteImportService->importFromPackage($packageKey);
         } catch (\Exception $exception) {
             $this->systemLogger->logException($exception);
             $this->outputLine('<error>During the import of the "Sites.xml" from the package "%s" an exception occurred: %s, see log for further information.</error>', array($packageKey, $exception->getMessage()));
             $this->quit(1);
         }
     }
     $this->outputLine('Import of site "%s" finished.', array($site->getName()));
 }
 /**
  * Import a site from site package.
  *
  * @param string $packageKey Package from where the import will come
  * @Flow\Validate(argumentName="$packageKey", type="\Neos\Neos\Validation\Validator\PackageKeyValidator")
  * @return void
  */
 public function importSiteAction($packageKey)
 {
     try {
         $this->siteImportService->importFromPackage($packageKey);
         $this->addFlashMessage('The site has been imported.', '', null, array(), 1412372266);
     } catch (\Exception $exception) {
         $this->systemLogger->logException($exception);
         $this->addFlashMessage('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', 'Import error', Message::SEVERITY_ERROR, array(htmlspecialchars($packageKey), htmlspecialchars($exception->getMessage())), 1412372375);
     }
     $this->unsetLastVisitedNodeAndRedirect('index');
 }