/**
  * Get a list of all Drupal extensions currently managed by the root package.
  *
  * This finds Drupal extensions in the root package of the current project. It
  * does not reconcile them against the file system.
  *
  * @param \Composer\Composer $composer
  *   The Composer object.
  *
  * @return Composer\Package\PackageInterface[]
  *   Composer packages representing Drupal modules managed in the root
  *   package, keyed by package type.
  */
 public function getComposerManagedExtensions(WritableRepositoryInterface $local_repository)
 {
     $types = ['drupal-module', 'drupal-theme', 'drupal-profile'];
     $packages = $local_repository->getPackages();
     $composer_managed_extensions = [];
     foreach ($packages as $package) {
         $package_type = $package->getType();
         if (in_array($package_type, $types)) {
             $composer_managed_extensions[$package_type] = $package;
         }
     }
     return $composer_managed_extensions;
 }
示例#2
0
 /**
  * @param WritableRepositoryInterface   $repo repository to purge packages from
  * @param Installer\InstallationManager $im   manager to check whether packages are still installed
  */
 protected function purgePackages(WritableRepositoryInterface $repo, Installer\InstallationManager $im)
 {
     foreach ($repo->getPackages() as $package) {
         if (!$im->isPackageInstalled($repo, $package)) {
             $repo->removePackage($package);
         }
     }
 }