示例#1
0
文件: Solver.php 项目: venne/packages
 /**
  * @param \Venne\Packages\IPackage $package
  * @param \Venne\Packages\DependencyResolver\Problem $problem
  */
 public function testUninstall(IPackage $package, Problem $problem = null)
 {
     $installedPackages =& $this->installedPackages;
     foreach ($installedPackages as $sourcePackage) {
         if ($sourcePackage->getName() === $package->getName()) {
             continue;
         }
         foreach ($sourcePackage->getRequire() as $name) {
             if ($name == $package->getName()) {
                 if ($problem) {
                     $solver = $this->createSolver();
                     $solver->testUninstall($sourcePackage, $problem);
                     $job = new Job(Job::ACTION_UNINSTALL, $sourcePackage);
                     if (!$problem->hasSolution($job)) {
                         $problem->addSolution($job);
                     }
                 } else {
                     throw new InvalidArgumentException(sprintf('Package \'%s\' depend on \'%s\'.', $sourcePackage->getName(), $package->getName()));
                 }
             }
         }
     }
 }
示例#2
0
 /**
  * Unregistration of package.
  *
  * @param \Venne\Packages\IPackage $package
  */
 private function unregister(IPackage $package)
 {
     $packageConfig =& $this->getPackageConfig();
     unset($packageConfig[$package->getName()]);
     $this->savePackageConfig();
     $this->onUnregister($this, $package);
 }
示例#3
0
 /**
  * @param \Venne\Packages\IPackage $package
  */
 public function uninstall(IPackage $package)
 {
     $name = $package->getName();
     $configuration = $package->getConfiguration();
     // update main config.neon
     if (count($configuration) > 0) {
         $orig = $data = $this->loadConfig();
         $data = $this->getRecursiveDiff($data, $configuration);
         // remove extension parameters
         $configuration = $package->getConfiguration();
         if (isset($configuration['extensions'])) {
             foreach ($configuration['extensions'] as $key => $values) {
                 if (isset($data[$key])) {
                     unset($data[$key]);
                 }
             }
         }
         $this->saveConfig($data);
         $this->actions[] = function ($self) use($orig) {
             $self->saveConfig($orig);
         };
     }
     // remove resources dir
     $resourcesDir = $this->resourcesDir . '/' . $name;
     if (is_dir($resourcesDir)) {
         if (is_link($resourcesDir)) {
             unlink($resourcesDir);
         } else {
             FileSystem::delete($resourcesDir);
         }
     }
 }