function pm_parse_request

8.0.x pm.drush.inc pm_parse_request($request_string, $status_url = NULL, &$projects = array())
7.x pm.drush.inc pm_parse_request($request_string, $status_url = NULL, &$projects = array())
master pm.drush.inc pm_parse_request($request_string, $status_url = NULL, &$projects = array())

Parse out the project name and version and return as a structured array.

Parameters

string $request_string: Project name with optional version. Examples: 'ctools-7.x-1.0-beta1'

Return value

array Array with all parts of the request info.

See also

pm_parse_version()

11 calls to pm_parse_request()
drush_pm_download in commands/pm/download.pm.inc
Command callback. Download Drupal core or any project.
drush_pm_enable_find_project_from_extension in commands/pm/pm.drush.inc
Helper function for pm-enable.
drush_pm_releasenotes in commands/pm/pm.drush.inc
Command callback. Show release notes for given project(s).
drush_pm_releases in commands/pm/pm.drush.inc
Command callback. Show available releases for given project(s).
drush_pm_updatestatus in commands/pm/updatestatus.pm.inc
Command callback. Displays update status info of installed projects.

... See full list

File

commands/pm/pm.drush.inc, line 1657
The drush Project Manager

Code

function pm_parse_request($request_string, $status_url = NULL, &$projects = array()) {
  $request = array();

  // Split $request_string in project name and version. Note that hyphens (-)
  // are permitted in project names (ex: field-conditional-state).
  // We use a regex to split the string. The pattern used matches a string
  // starting with hyphen, followed by one or more numbers, any of the valid
  // symbols in version strings (.x-) and a catchall for the rest of the
  // version string.
  $parts = preg_split('/-(?:([\d+\.x].*))?$/', $request_string, NULL, PREG_SPLIT_DELIM_CAPTURE);

  if (count($parts) == 1) {
    // No version in the request string.
    $project = $request_string;
    $version = '';
  }
  else {
    $project = $parts[0];
    $version = $parts[1];
  }

  $is_core = ($project == 'drupal');
  $request = array(
    'name' => $project,
  ) + pm_parse_version($version, $is_core);

  // Set the status url if provided or available in project's info file.
  if ($status_url) {
    $request['status url'] = $status_url;
  }
  elseif (!empty($projects[$project]['status url'])) {
    $request['status url'] = $projects[$project]['status url'];
  }

  return $request;
}