function _drush_make_generate_projects

8.0.x generate.make.inc _drush_make_generate_projects($all_extensions, $version_options)
6.x generate.make.inc _drush_make_generate_projects($all_extensions, $version_options)
7.x generate.make.inc _drush_make_generate_projects($all_extensions, $version_options)
5.x generate.make.inc _drush_make_generate_projects($all_extensions, $version_options)
master generate.make.inc _drush_make_generate_projects($all_extensions, $version_options)

Generate the $projects makefile array for the current site.

1 call to _drush_make_generate_projects()
drush_make_generate in commands/make/generate.make.inc
Drush callback; generate makefile from the current build.

File

commands/make/generate.make.inc, line 43
Functions for the generate makefile command.

Code

function _drush_make_generate_projects($all_extensions, $version_options) {
  $release_info = drush_get_engine('release_info');

  $projects = array();
  $project_libraries = array();

  $system_requirements = system_requirements('runtime');
  // Update xml expects the drupal version to be expressed as "7.x" or "8.x"
  // We used to check $system_requirements['drupal']['value'], but this now
  // contains values such as "7.10-dev".
  $drupal_major_version = drush_drupal_major_version() . '.x';
  $core_project = strtolower($system_requirements['drupal']['title']);
  $projects[$core_project] = array('_type' => 'core');
  if ($core_project != 'drupal') {
    $projects[$core_project]['custom_download'] = TRUE;
    $projects[$core_project]['type'] = 'core';
  }
  else {
    // Drupal core - we can determine the version if required.
    if (_drush_generate_track_version("drupal", $version_options)) {
      $projects[$core_project]["version"] = drush_drupal_version();
    }
  }

  $install_profile = drush_drupal_major_version() >= 7 ? drupal_get_profile() : variable_get('install_profile', '');
  if (!in_array($install_profile, array('default', 'standard', 'minimal', 'testing')) && $install_profile != '') {
    $projects[$install_profile]['type'] = $projects[$install_profile]['_type'] = 'profile';
    $request = array(
      'name' => $install_profile,
      'drupal_version' => $drupal_major_version,
    );
    if (!$release_info->checkProject($request, 'profile')) {
      $projects[$install_profile]['custom_download'] = TRUE;
    }
  }

  // Iterate installed projects to build $projects array.
  $extensions = $all_extensions;
  $project_info = drush_get_projects($extensions);
  foreach ($project_info as $name => $project) {
    // Discard the extensions within this project. At the end $extensions will
    // contain only extensions part of custom projects (not from drupal.org or
    // other update service).
    foreach ($project['extensions'] as $ext) {
      unset($extensions[$ext]);
    }
    if ($name == 'drupal') {
      continue;
    }
    $type = $project['type'];
    // Discard projects with all modules disabled.
    if (($type == 'module') && (!$project['status'])) {
      continue;
    }
    $projects[$name] = array('_type' => $type);
    // Check the project is on drupal.org or its own update service.
    $request = array(
      'name' => $name,
      'drupal_version' => $drupal_major_version,
    );
    if (isset($project['status url'])) {
      $request['status url'] = $project['status url'];
      $projects[$name]['location'] = $project['status url'];
    }
    if (!$release_info->checkProject($request, $type)) {
      // It is not a project on drupal.org neither an external update service.
      $projects[$name]['type'] = $type;
      $projects[$name]['custom_download'] = TRUE;
    }
    // Add 'subdir' if the project is installed in a non-default location.
    if (isset($project['path'])) {
      $projects[$name] += _drush_generate_makefile_check_path($project);
    }
    // Add version number if this project's version is to be tracked.
    if (_drush_generate_track_version($name, $version_options) && $project["version"]) {
      $version = preg_replace("/^" . drush_get_drupal_core_compatibility() . "-/", "", $project["version"]);
      // Strip out MINOR+GIT_COMMIT strings for dev releases.
      if (substr($version, -4) == '-dev' && strpos($version, '+')) {
        $version = substr($version, 0, strrpos($version, '.')) . '.x-dev';
      }
      $projects[$name]['version'] = $version;
    }
    foreach ($project['extensions'] as $extension_name) {
      _drush_make_generate_add_patch_files($projects[$name], _drush_extension_get_path($all_extensions[$extension_name]));
    }
  }

  // Add a project for each unknown extension.
  foreach ($extensions as $name => $extension) {
    list($project_name, $project_data) = _drush_generate_custom_project($name, $extension, $version_options);
    $projects[$project_name] = $project_data;
  }

  // Add libraries.
  if (function_exists('libraries_get_libraries')) {
    $libraries = libraries_get_libraries();
    foreach ($libraries as $library_name => $library_path) {
      $path = explode('/', $library_path);
      $project_libraries[$library_name] = array(
        'directory_name' => $path[(count($path) - 1)],
        'custom_download' => TRUE,
        'type' => 'library',
        '_type' => 'librarie', // For plural.
      );
    }
  }
  return array($projects, $project_libraries);
}