/**
  * Removes a target from the collection.
  *
  * If the target does not exist, this method does nothing.
  *
  * @param string $targetName The target name.
  */
 public function remove($targetName)
 {
     if (InstallTarget::DEFAULT_TARGET === $targetName && $this->defaultTarget) {
         $targetName = $this->defaultTarget->getName();
     }
     unset($this->targets[$targetName]);
     if ($this->defaultTarget && $targetName === $this->defaultTarget->getName()) {
         $this->defaultTarget = $this->targets ? reset($this->targets) : null;
     }
 }
Esempio n. 2
0
 public function testMatch()
 {
     $target = new InstallTarget('local', 'symlink', 'web', '/%s', array('param1' => 'value1', 'param2' => 'value2'));
     $this->assertFalse($target->match(Expr::same('foobar', InstallTarget::NAME)));
     $this->assertTrue($target->match(Expr::same('local', InstallTarget::NAME)));
     $this->assertFalse($target->match(Expr::same('foobar', InstallTarget::INSTALLER_NAME)));
     $this->assertTrue($target->match(Expr::same('symlink', InstallTarget::INSTALLER_NAME)));
     $this->assertFalse($target->match(Expr::same('foobar', InstallTarget::LOCATION)));
     $this->assertTrue($target->match(Expr::same('web', InstallTarget::LOCATION)));
     $this->assertFalse($target->match(Expr::same('foobar', InstallTarget::URL_FORMAT)));
     $this->assertTrue($target->match(Expr::same('/%s', InstallTarget::URL_FORMAT)));
     $this->assertFalse($target->match(Expr::key(InstallTarget::PARAMETER_VALUES, Expr::keyExists('foobar'))));
     $this->assertTrue($target->match(Expr::key(InstallTarget::PARAMETER_VALUES, Expr::keyExists('param1'))));
 }
 private function targetToData(InstallTarget $target)
 {
     $data = new stdClass();
     $data->installer = $target->getInstallerName();
     $data->location = $target->getLocation();
     if (InstallTarget::DEFAULT_URL_FORMAT !== ($urlFormat = $target->getUrlFormat())) {
         $data->{'url-format'} = $urlFormat;
     }
     if ($parameters = $target->getParameterValues()) {
         $data->parameters = (object) $parameters;
     }
     return $data;
 }
Esempio n. 4
0
 private function targetsEqual(InstallTarget $target1, InstallTarget $target2)
 {
     if ($target1->getName() !== $target2->getName()) {
         return false;
     }
     if ($target1->getInstallerName() !== $target2->getInstallerName()) {
         return false;
     }
     if ($target1->getLocation() !== $target2->getLocation()) {
         return false;
     }
     if ($target1->getUrlFormat() !== $target2->getUrlFormat()) {
         return false;
     }
     $parameters1 = $target1->getParameterValues();
     $parameters2 = $target2->getParameterValues();
     ksort($parameters1);
     ksort($parameters2);
     if ($parameters1 !== $parameters2) {
         return false;
     }
     return true;
 }
Esempio n. 5
0
 /**
  * Returns the location string of the install target.
  *
  * This can be a directory name, a URL or any other string that can be
  * interpreted by the installer.
  *
  * @return string The target location.
  */
 public function getTargetLocation()
 {
     return $this->installTarget->getLocation();
 }