예제 #1
0
 public function testClearInstallInfos()
 {
     $installInfo1 = new InstallInfo('vendor/package1', '/path/to/package1');
     $installInfo2 = new InstallInfo('vendor/package2', '/path/to/package2');
     $this->packageFile->addInstallInfo($installInfo1);
     $this->packageFile->addInstallInfo($installInfo2);
     $this->packageFile->clearInstallInfos();
     $this->assertSame(array(), $this->packageFile->getInstallInfos());
 }
예제 #2
0
 /**
  * Loads all packages referenced by the install file.
  *
  * @throws FileNotFoundException If the install path of a package not exist.
  * @throws NoDirectoryException If the install path of a package points to a
  *                              file.
  * @throws InvalidConfigException If a package is not configured correctly.
  * @throws NameConflictException If a package has the same name as another
  *                               loaded package.
  */
 private function loadPackages()
 {
     $this->packages = new PackageCollection();
     $this->packages->add(new RootPackage($this->rootPackageFile, $this->rootDir));
     foreach ($this->rootPackageFile->getInstallInfos() as $installInfo) {
         // Catch and log exceptions so that single packages cannot break
         // the whole repository
         $this->packages->add($this->loadPackage($installInfo));
     }
 }
예제 #3
0
 private function addRootConfig(array &$jsonData, RootPackageFile $packageFile)
 {
     $overrideOrder = $packageFile->getOverrideOrder();
     $installInfos = $packageFile->getInstallInfos();
     // Pass false to exclude base configuration values
     $configValues = $packageFile->getConfig()->toRawArray(false);
     if (count($overrideOrder) > 0) {
         $jsonData['override-order'] = $overrideOrder;
     }
     if (count($configValues) > 0) {
         $jsonData['config'] = (object) $configValues;
     }
     if (array() !== $packageFile->getPluginClasses(false)) {
         $jsonData['plugins'] = $packageFile->getPluginClasses();
         sort($jsonData['plugins']);
     }
     if (count($installInfos) > 0) {
         $packagesData = array();
         foreach ($installInfos as $installInfo) {
             $installData = new stdClass();
             $installData->{'install-path'} = $installInfo->getInstallPath();
             if (InstallInfo::DEFAULT_INSTALLER_NAME !== $installInfo->getInstallerName()) {
                 $installData->installer = $installInfo->getInstallerName();
             }
             if ($installInfo->hasEnabledBindingUuids()) {
                 $installData->{'enabled-bindings'} = array();
                 foreach ($installInfo->getEnabledBindingUuids() as $uuid) {
                     $installData->{'enabled-bindings'}[] = $uuid->toString();
                 }
                 sort($installData->{'enabled-bindings'});
             }
             if ($installInfo->hasDisabledBindingUuids()) {
                 $installData->{'disabled-bindings'} = array();
                 foreach ($installInfo->getDisabledBindingUuids() as $uuid) {
                     $installData->{'disabled-bindings'}[] = $uuid->toString();
                 }
                 sort($installData->{'disabled-bindings'});
             }
             $packagesData[$installInfo->getPackageName()] = $installData;
         }
         ksort($packagesData);
         $jsonData['packages'] = (object) $packagesData;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function removeObsoleteDisabledBindingDescriptors()
 {
     $this->assertPackagesLoaded();
     $removedUuidsByPackage = array();
     try {
         foreach ($this->rootPackageFile->getInstallInfos() as $installInfo) {
             foreach ($installInfo->getDisabledBindingUuids() as $uuid) {
                 if (!$this->bindingDescriptors->contains($uuid)) {
                     $installInfo->removeDisabledBindingUuid($uuid);
                     $removedUuidsByPackage[$installInfo->getPackageName()][] = $uuid;
                 }
             }
         }
         $this->saveRootPackageFile();
     } catch (Exception $e) {
         foreach ($removedUuidsByPackage as $packageName => $removedUuids) {
             $installInfo = $this->rootPackageFile->getInstallInfo($packageName);
             foreach ($removedUuids as $uuid) {
                 $installInfo->addDisabledBindingUuid($uuid);
             }
         }
         throw $e;
     }
 }