/**
  * Writes a local drush alias file.
  */
 public function writeDrushAlias()
 {
     $drush_alias_file_path = "{$_SERVER['HOME']}/.drush/{$this->app->name}.aliases.drushrc.php";
     $drush_alias_file = array();
     $drush_alias_file[] = '<?php';
     foreach ($this->app->environments as $environment_name => $environment) {
         $factory = new self($environment, $this->app);
         $path = "/source/" . $environment['document_root'];
         $drush_alias_file[] = '// DO NOT EDIT. This is generated by Terra. Any changes will be overridden when the environment is re-enabled.';
         $drush_alias_file[] = "\$aliases['{$environment_name}'] = array(";
         $drush_alias_file[] = "  'uri' => '{$factory->getHost()}:{$factory->getPort()}',";
         $drush_alias_file[] = "  'root' => '{$path}',";
         $drush_alias_file[] = "  'remote-host' => '{$factory->getHost()}',";
         $drush_alias_file[] = "  'remote-user' => 'root',";
         $drush_alias_file[] = "  'ssh-options' => '-p {$factory->getDrushPort()}',";
         $drush_alias_file[] = ');';
     }
     $fs = new FileSystem();
     try {
         $fs->dumpFile($drush_alias_file_path, implode("\n", $drush_alias_file));
         return true;
     } catch (IOException $e) {
         return false;
     }
 }
Example #2
0
 /**
  *    Replaces unknown sections to turn a relative
  *    URL into an absolute one. The base URL can
  *    be either a string or a SimpleUrl object.
  *
  *    @param string/SimpleUrl $base       Base URL.
  */
 public function makeAbsolute($base)
 {
     if (!is_object($base)) {
         $base = new self($base);
     }
     if ($this->getHost()) {
         $scheme = $this->getScheme();
         $host = $this->getHost();
         $port = $this->getPort() ? ':' . $this->getPort() : '';
         $identity = $this->getIdentity() ? $this->getIdentity() . '@' : '';
         if (!$identity) {
             $identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
         }
     } else {
         $scheme = $base->getScheme();
         $host = $base->getHost();
         $port = $base->getPort() ? ':' . $base->getPort() : '';
         $identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
     }
     $path = $this->normalisePath($this->_extractAbsolutePath($base));
     $encoded = $this->getEncodedRequest();
     $fragment = $this->getFragment() ? '#' . $this->getFragment() : '';
     $coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
     return new self("{$scheme}://{$identity}{$host}{$port}{$path}{$encoded}{$fragment}{$coords}");
 }
Example #3
0
File: Url.php Project: jave007/test
 /**
  * URL comparison.
  * @param  string|self
  * @return bool
  */
 public function isEqual($url)
 {
     $url = new self($url);
     $query = $url->query;
     ksort($query);
     $query2 = $this->query;
     ksort($query2);
     $http = in_array($this->scheme, array('http', 'https'), TRUE);
     return $url->scheme === $this->scheme && !strcasecmp($url->host, $this->host) && $url->getPort() === $this->getPort() && ($http || $url->user === $this->user) && ($http || $url->password === $this->password) && self::unescape($url->path, '%/') === self::unescape($this->path, '%/') && $query === $query2 && $url->fragment === $this->fragment;
 }
Example #4
0
 /**
  * URL comparison.
  *
  * @param string $url            
  * @return bool
  */
 public function isEqual($url)
 {
     $url = new self($url);
     $query = $url->query;
     sort($query);
     $query2 = $this->query;
     sort($query2);
     $http = in_array($this->scheme, array("http", "https"), true);
     return $url->scheme === $this->scheme && !strcasecmp($url->host, $this->host) && $url->getPort() === $this->getPort() && ($http || $url->user === $this->user) && ($http || $url->pass === $this->pass) && self::unescape($url->path, "%/") === self::unescape($this->path, "%/") && $query === $query2 && $url->fragment === $this->fragment;
 }