You are here

function replication_get_url_parts in Replication 8

Same name and namespace in other branches
  1. 8.2 replication.drush.inc \replication_get_url_parts()

Returns url parts (host, port, path, user and pass).

Parameters

$url:

bool $credentials:

Return value

array

1 call to replication_get_url_parts()
drush_replication_active in ./replication.drush.inc
Implements drush_hook_COMMAND().

File

./replication.drush.inc, line 326
Drush integration for the replication module.

Code

function replication_get_url_parts($url, $credentials = FALSE) {
  $url_parts = parse_url($url);
  $options = [
    'host' => $url_parts['host'],
    'port' => $url_parts['port'],
  ];
  $path = trim($url_parts['path'], '/');
  if ($path != '') {
    $options['path'] = $path;
  }
  if ($credentials) {
    $options['user'] = $url_parts['user'] ? $url_parts['user'] : NULL;
    $options['password'] = $url_parts['pass'] ? $url_parts['pass'] : NULL;
  }
  return $options;
}