Esempio n. 1
0
 /**
  * Read the option called $optionName from $this->options, and parse {...}
  * as object accessors.
  *
  * if $optionName was not found, the corresponding default option is returned (from $this->defaultOptions)
  *
  * @param string $optionName
  * @return mixed
  * @api
  */
 protected function parseOption($optionName)
 {
     if (!isset($this->options[$optionName]) || $this->options[$optionName] === '') {
         if (isset($this->defaultOptions[$optionName])) {
             $option = $this->defaultOptions[$optionName];
         } else {
             return null;
         }
     } else {
         $option = $this->options[$optionName];
     }
     if (!is_string($option)) {
         return $option;
     }
     $formRuntime = $this->finisherContext->getFormRuntime();
     return preg_replace_callback('/{([^}]+)}/', function ($match) use($formRuntime) {
         return \Neos\Utility\ObjectAccess::getPropertyPath($formRuntime, $match[1]);
     }, $option);
 }
 /**
  * @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);
         }
     }
 }
Esempio n. 3
0
 /**
  * @test
  */
 public function isCancelReturnsTrueIfContextHasBeenCancelled()
 {
     $this->finisherContext->cancel();
     $this->assertTrue($this->finisherContext->isCancelled());
 }