Ejemplo n.º 1
0
 public function handleUpdate(Args $args)
 {
     $targetName = $args->getArgument('name');
     if (!$this->targetManager->hasTarget($targetName)) {
         throw NoSuchTargetException::forTargetName($targetName);
     }
     $targetToUpdate = $this->targetManager->getTarget($targetName);
     $installerName = $targetToUpdate->getInstallerName();
     $location = $targetToUpdate->getLocation();
     $urlFormat = $targetToUpdate->getUrlFormat();
     $parameters = $targetToUpdate->getParameterValues();
     if ($args->isOptionSet('installer')) {
         $installerName = $args->getOption('installer');
     }
     if ($args->isOptionSet('location')) {
         $location = $args->getOption('location');
     }
     if ($args->isOptionSet('url-format')) {
         $urlFormat = $args->getOption('url-format');
     }
     $this->parseParams($args, $parameters);
     $this->unsetParams($args, $parameters);
     $updatedTarget = new InstallTarget($targetName, $installerName, $location, $urlFormat, $parameters);
     if ($this->targetsEqual($targetToUpdate, $updatedTarget)) {
         throw new RuntimeException('Nothing to update.');
     }
     $this->targetManager->addTarget($updatedTarget);
     return 0;
 }