/**
  * Unloads given extension
  *
  * Warning: This method only works if the ugrade wizard to transform
  * localconf.php to LocalConfiguration.php was already run
  *
  * @param string $extensionKey Extension key to remove
  * @return void
  * @throws \RuntimeException
  */
 public static function unloadExtension($extensionKey)
 {
     if (!static::$packageManager->isPackageActive($extensionKey)) {
         throw new \RuntimeException('Extension not loaded', 1342345487);
     }
     static::$packageManager->deactivatePackage($extensionKey);
 }
 /**
  * Activates all packages that are configured in root composer.json or are required
  *
  * @param bool $removeInactivePackages
  */
 public function generatePackageStatesCommand($removeInactivePackages = FALSE)
 {
     try {
         $installationPackages = $this->getPackagesFromRootComposerFile();
     } catch (\Exception $e) {
         $this->outputLine('<error>' . $e->getMessage() . '</error>');
         $this->quit(1);
         return;
     }
     foreach ($this->packageManager->getAvailablePackages() as $package) {
         if (isset($installationPackages[$package->getPackageKey()]) || $package->isProtected() || $package instanceof Package && $package->isPartOfMinimalUsableSystem()) {
             $this->packageManager->activatePackage($package->getPackageKey());
         } else {
             try {
                 $this->packageManager->deactivatePackage($package->getPackageKey());
             } catch (\UnexpectedValueException $exception) {
                 $this->outputLine('<info>Error while deactivating package %s. Exception: %s</info>', array($package->getPackageKey(), $exception->getMessage()));
             }
             if ($removeInactivePackages) {
                 $this->packageManager->unregisterPackage($package);
                 GeneralUtility::flushDirectory($package->getPackagePath());
                 $this->outputLine('Removed Package: ' . $package->getPackageKey());
             }
         }
     }
     $this->packageManager->forceSortAndSavePackageStates();
 }
 /**
  * Activates all packages that are configured in root composer.json or are required
  *
  * @param bool $removeInactivePackages
  */
 public function generatePackageStatesCommand($removeInactivePackages = FALSE)
 {
     $installationPackages = $this->getPackagesFromRootComposerFile();
     foreach ($this->packageManager->getAvailablePackages() as $package) {
         if (in_array($package->getPackageKey(), $installationPackages) || $package->isProtected() || $package instanceof Package && $package->isPartOfMinimalUsableSystem()) {
             $this->packageManager->activatePackage($package->getPackageKey());
         } else {
             $this->packageManager->deactivatePackage($package->getPackageKey());
             if ($removeInactivePackages) {
                 $this->packageManager->unregisterPackage($package);
                 GeneralUtility::flushDirectory($package->getPackagePath());
                 $this->outputLine('Removed Package: ' . $package->getPackageKey());
             }
         }
     }
     $this->packageManager->forceSortAndSavePackageStates();
 }
 /**
  * @test
  * @expectedException \TYPO3\CMS\Core\Package\Exception\ProtectedPackageKeyException
  */
 public function deactivatePackageThrowsAnExceptionIfPackageIsProtected()
 {
     $package = $this->createPackage('Acme.YetAnotherTestPackage');
     $package->setProtected(true);
     $this->packageManager->deactivatePackage('Acme.YetAnotherTestPackage');
 }
 /**
  * Wrapper function for unloading extensions
  *
  * @param string $extensionKey
  * @return void
  */
 protected function unloadExtension($extensionKey)
 {
     $this->packageManager->deactivatePackage($extensionKey);
     $this->cacheManager->flushCachesInGroup('system');
 }