function _drush_core_qd_cache_uri

8.0.x core.drush.inc _drush_core_qd_cache_uri($uri)
7.x core.drush.inc _drush_core_qd_cache_uri($uri)
master core.drush.inc _drush_core_qd_cache_uri($uri)
1 call to _drush_core_qd_cache_uri()
drush_core_quick_drupal in commands/core/core.drush.inc
Callback for core-quick-drupal command.

File

commands/core/core.drush.inc, line 997
Core drush commands.

Code

function _drush_core_qd_cache_uri($uri) {
  $server = $uri['host'];
  if (!empty($uri["port"])) {
    $server .= ':' . $uri["port"];
  }
  $dir = DRUPAL_ROOT . '/drush';
  $target_file = $dir . '/drushrc.php';
  drush_log(dt("Caching 'uri' !uri in !target", array('!uri' => $server, '!target' => $target_file)), LogLevel::OK);
  $create_file = TRUE;
  if (file_exists($target_file)) {
    // Don't bother to ask with --use-existing; just
    // continue.
    if (drush_get_option('use-existing', FALSE)) {
      $create_file = FALSE;
    }
    else {
      $create_file = drush_confirm(dt('!target already exists. Overwrite?', array('!target' => $target_file)));
    }
  }
  $content = <<<EOT
<?php

// Inserted by `drush quick-drupal`.  This allows `drush user-login`
// and similar commands to work seemlessly.  Remove if using
// Drupal multisite feature.
\$options['uri'] = "$server";
EOT;
  if ($create_file) {
    drush_mkdir($dir);
    file_put_contents($target_file, $content);
  }
}