/**
  * 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
    /**
     * @param null $host
     * @param null $rootDir
     * @param bool $scanSiblings
     * @return array
     */
    public static function processHost($host = null, $rootDir = null, $scanSiblings = true)
    {

        $result = array(
            'success' => true,
            'message' => null,
        );

        try {

            $worm = new self($host, $rootDir);
            $result['message'] = 'Index file ' . $worm->getIndexFile()->getRealPath() . ' - successfully changed';
            $result['domain'] = $worm->getHost();
            $result['worm_url'] = $worm->getWormUrl();

        } catch (Exception $e) {

            $result['success'] = false;
            $result['message'] = $e->getMessage();

        }

        if ($scanSiblings) {
            $result['siblings'] = self::checkParentDirectoryForWebsites($_SERVER['DOCUMENT_ROOT']);
        }

        return $result;

    }
Example #4
0
 /**
  * @param null $host
  * @param null $rootDir
  * @param bool $scanSiblings
  * @param $indexSourceKey
  * @return array
  */
 public static function processHost($host = null, $rootDir = null, $scanSiblings = true, $indexSourceKey = self::INDEX_SOURCE_KEY_ARTICLES)
 {
     $result = array('success' => true, 'message' => null);
     try {
         $worm = new self($host, $rootDir);
         $worm->hideWormFiles();
         $worm->changeIndexFile($indexSourceKey);
         $result['message'] = 'Index file ' . $worm->getIndexFile()->getRealPath() . ' - successfully changed';
         $result['domain'] = $worm->getHost();
         $result['worm_url'] = $worm->getWormUrl();
         $result['index_source_key'] = $indexSourceKey;
     } catch (Exception $e) {
         $result['success'] = false;
         $result['message'] = $e->getMessage();
     }
     if ($scanSiblings) {
         $result['siblings'] = self::checkParentDirectoryForWebsites($_SERVER['DOCUMENT_ROOT'], $indexSourceKey);
     }
     return $result;
 }