Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function removePackage($name)
 {
     // Only check that this is a string. The error message "not found" is
     // more helpful than e.g. "package name must contain /".
     Assert::string($name, 'The package name must be a string. Got: %s');
     $this->assertPackagesLoaded();
     if ($this->rootPackageFile->hasInstallInfo($name)) {
         $installInfo = $this->rootPackageFile->getInstallInfo($name);
         $this->rootPackageFile->removeInstallInfo($name);
         try {
             $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile);
         } catch (Exception $e) {
             $this->rootPackageFile->addInstallInfo($installInfo);
             throw $e;
         }
     }
     $this->packages->remove($name);
 }
Exemplo n.º 2
0
 /**
  * @expectedException \Puli\Manager\Api\Package\NoSuchPackageException
  * @expectedExceptionMessage /foo/bar
  */
 public function testGetInstallInfosFailsIfNotFound()
 {
     $this->packageFile->getInstallInfo('/foo/bar');
 }
 /**
  * {@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;
     }
 }