function drush_make_convert_project_to_composer

master make.drush.inc drush_make_convert_project_to_composer($original_project, $core_major_version)

Converts a make file project array into a composer project version string.

Parameters

array $original_project: A project dependency, as defined in a make file.

string $core_major_version: The major core version. E.g., 6, 7, 8, etc.

Return value

string The project version, in composer syntax.

1 call to drush_make_convert_project_to_composer()
drush_make_convert_make_to_composer in commands/make/make.drush.inc
Converts a drush info array to a composer.json array.

File

commands/make/make.drush.inc, line 560
Drush Make commands.

Code

function drush_make_convert_project_to_composer($original_project, $core_major_version) {
  // Typical specified version with major version "x" removed.
  if (!empty($original_project['version'])) {
    $version = str_replace('x', '0', $original_project['version']);
  }
  // Git branch or revision.
  elseif (!empty($original_project['download'])) {
    switch ($original_project['download']['type']) {
      case 'git':
        if (!empty($original_project['download']['branch'])) {
          // @todo Determine if '0' will always be correct.
          $version = str_replace('x', '0', $original_project['download']['branch']);
        }
        if (!empty($original_project['download']['tag'])) {
          // @todo Determine if '0' will always be correct.
          $version = str_replace('x', '0', $original_project['download']['tag']);
        }
        if (!empty($project['download']['revision'])) {
          $version .= '#' . $original_project['download']['revision'];
        }
        break;

      default:
        $version = 'Enter correct project name and version number';
        break;
    }
  }

  $version = "$core_major_version." . $version;

  return $version;
}