activatePackage() public method

Activates a package
public activatePackage ( string $packageKey ) : void
$packageKey string The package to activate
return void
 /**
  * @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);
         }
     }
 }
 /**
  * @param string $packageKey
  * @return Error|Message
  */
 protected function activatePackage($packageKey)
 {
     try {
         $this->packageManager->activatePackage($packageKey);
         $message = new Message('The package %s is activated', 1343231680, array($packageKey));
     } catch (UnknownPackageException $exception) {
         $message = new Error('The package %s is not present and can not be activated', 1343231681, array($packageKey));
     }
     return $message;
 }
 /**
  * Activate an available package
  *
  * This command activates an existing, but currently inactive package.
  *
  * @Flow\FlushesCaches
  * @param string $packageKey The package key of the package to create
  * @return string
  * @see neos.flow:package:deactivate
  */
 public function activateCommand($packageKey)
 {
     if (!$this->packageManager->isPackageAvailable($packageKey)) {
         $this->outputLine('The package "%s" does not exist.', [$packageKey]);
         $this->quit(1);
     }
     if ($this->packageManager->isPackageActive($packageKey)) {
         $this->outputLine('Package "%s" is already active.', [$packageKey]);
         $this->quit(1);
     }
     $this->packageManager->activatePackage($packageKey);
     $this->outputLine('Activated package "%s".', [$packageKey]);
     Scripts::executeCommand('neos.flow:cache:flush', $this->settings, false);
     $this->sendAndExit(0);
 }
 /**
  * Create a new site-package and directly import it.
  *
  * @param string $packageKey Package Name to create
  * @param string $siteName Site Name to create
  * @Flow\Validate(argumentName="$packageKey", type="\Neos\Neos\Validation\Validator\PackageKeyValidator")
  * @return void
  */
 public function createSitePackageAction($packageKey, $siteName)
 {
     if ($this->packageManager->isPackageActive('Neos.SiteKickstarter') === false) {
         $this->addFlashMessage('The package "%s" is required to create new site packages.', 'Missing Package', Message::SEVERITY_ERROR, array('Neos.SiteKickstarter'), 1475736232);
         $this->redirect('index');
     }
     if ($this->packageManager->isPackageAvailable($packageKey)) {
         $this->addFlashMessage('The package key "%s" already exists.', 'Invalid package key', Message::SEVERITY_ERROR, array(htmlspecialchars($packageKey)), 1412372021);
         $this->redirect('index');
     }
     $generatorService = $this->objectManager->get(GeneratorService::class);
     $generatorService->generateSitePackage($packageKey, $siteName);
     $this->flashMessageContainer->addMessage(new Message(sprintf('Site Packages "%s" was created.', htmlspecialchars($packageKey))));
     $deactivatedSitePackages = $this->deactivateAllOtherSitePackages($packageKey);
     if (count($deactivatedSitePackages) > 0) {
         $this->flashMessageContainer->addMessage(new Message(sprintf('The existing Site Packages "%s" were deactivated, in order to prevent interactions with the newly created package "%s".', htmlspecialchars(implode(', ', $deactivatedSitePackages)), htmlspecialchars($packageKey))));
     }
     $this->packageManager->activatePackage($packageKey);
     $this->forward('importSite', null, null, ['packageKey' => $packageKey]);
 }