Ejemplo n.º 1
0
 public function handleRemove(Args $args)
 {
     $installerName = $args->getArgument('name');
     if (!$this->installerManager->hasInstallerDescriptor($installerName)) {
         throw new RuntimeException(sprintf('The installer "%s" does not exist.', $installerName));
     }
     $this->installerManager->removeRootInstallerDescriptor($installerName);
     return 0;
 }
 /**
  * {@inheritdoc}
  */
 public function addTarget(InstallTarget $target)
 {
     $this->assertTargetsLoaded();
     if (!$this->installerManager->hasInstallerDescriptor($target->getInstallerName())) {
         throw NoSuchInstallerException::forInstallerName($target->getInstallerName());
     }
     $previousTargets = $this->targets->toArray();
     $previousData = $this->targetsData;
     $this->targets->add($target);
     $this->targetsData[$target->getName()] = $this->targetToData($target);
     try {
         $this->persistTargetsData();
     } catch (Exception $e) {
         $this->targets->replace($previousTargets);
         $this->targetsData = $previousData;
         throw $e;
     }
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function prepareInstallation(AssetMapping $mapping)
 {
     $glob = $mapping->getGlob();
     $targetName = $mapping->getTargetName();
     $resources = $this->repo->find($glob);
     if ($resources->isEmpty()) {
         throw NotInstallableException::noResourceMatches($glob);
     }
     if (!$this->installTargets->contains($targetName)) {
         throw NotInstallableException::targetNotFound($targetName);
     }
     $target = $this->installTargets->get($targetName);
     $installerName = $target->getInstallerName();
     if (!$this->installerManager->hasInstallerDescriptor($installerName)) {
         throw NotInstallableException::installerNotFound($installerName);
     }
     $installerDescriptor = $this->installerManager->getInstallerDescriptor($installerName);
     $installer = $this->loadInstaller($installerDescriptor);
     $rootDir = $this->environment->getRootDirectory();
     $params = new InstallationParams($installer, $installerDescriptor, $resources, $mapping, $target, $rootDir);
     $installer->validateParams($params);
     return $params;
 }