/**
  * @param string $packageKey
  * @return Error|Message
  */
 protected function deactivatePackage($packageKey)
 {
     try {
         $this->packageManager->deactivatePackage($packageKey);
         $message = new Message('%s was deactivated', 1343231678, array($packageKey));
     } catch (ProtectedPackageKeyException $exception) {
         $message = new Error('The package %s is protected and can not be deactivated', 1343231679, array($packageKey));
     }
     return $message;
 }
 /**
  * If site packages already exist and are active, we will deactivate them in order to prevent
  * interactions with the newly created or imported package (like Content Dimensions being used).
  *
  * @param string $activePackageKey Package key of one package which should stay active
  * @return array deactivated site packages
  */
 protected function deactivateAllOtherSitePackages($activePackageKey)
 {
     $sitePackagesToDeactivate = $this->packageManager->getFilteredPackages('active', null, 'typo3-flow-site');
     $deactivatedSitePackages = array();
     foreach (array_keys($sitePackagesToDeactivate) as $packageKey) {
         if ($packageKey !== $activePackageKey) {
             $this->packageManager->deactivatePackage($packageKey);
             $deactivatedSitePackages[] = $packageKey;
         }
     }
     return $deactivatedSitePackages;
 }
 /**
  * If Site Packages already exist and are active, we will deactivate them in order to prevent
  * interactions with the newly created or imported package (like Content Dimensions being used).
  *
  * @param string $packageKey
  * @return array
  */
 protected function deactivateOtherSitePackages($packageKey)
 {
     $sitePackagesToDeactivate = $this->packageManager->getFilteredPackages('active', NULL, 'typo3-flow-site');
     $deactivatedSitePackages = array();
     foreach ($sitePackagesToDeactivate as $sitePackageToDeactivate) {
         if ($sitePackageToDeactivate->getPackageKey() !== $packageKey) {
             $this->packageManager->deactivatePackage($sitePackageToDeactivate->getPackageKey());
             $deactivatedSitePackages[] = $sitePackageToDeactivate->getPackageKey();
         }
     }
     if (count($deactivatedSitePackages) >= 1) {
         $this->flashMessageContainer->addMessage(new Message(sprintf('The existing Site Packages "%s" were deactivated, in order to prevent interactions with the newly created package "%s".', implode(', ', $deactivatedSitePackages), $packageKey)));
     }
 }
 /**
  * Deactivate a package
  *
  * This command deactivates a currently active package.
  *
  * @Flow\FlushesCaches
  * @param string $packageKey The package key of the package to create
  * @return string
  * @see typo3.flow:package:activate
  */
 public function deactivateCommand($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" was not active.', [$packageKey]);
         $this->quit(1);
     }
     $this->packageManager->deactivatePackage($packageKey);
     $this->outputLine('Deactivated package "%s".', [$packageKey]);
     Scripts::executeCommand('typo3.flow:cache:flush', $this->settings, false);
     $this->sendAndExit(0);
 }
 /**
  * @param string $packageKey
  * @return void
  */
 public function deactivateAction($packageKey)
 {
     if ($this->packageManager->isPackageAvailable($packageKey) === false) {
         $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Package ' . $packageKey . ' does not exists.'));
         $this->redirect('index');
     }
     if ($this->packageManager->isPackageActive($packageKey) === false) {
         $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Package ' . $packageKey . ' is currently not activated.'));
         $this->redirect('index');
     }
     if ($requiredBy = $this->packageDependencyService->getPackageRequirements($packageKey)) {
         $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Package ' . $packageKey . ' is required by ' . $requiredBy));
         $this->redirect('index');
     }
     $this->packageManager->deactivatePackage($packageKey);
     $this->redirect('index');
 }