function drush_pm_extensions_in_project

8.0.x pm.drush.inc drush_pm_extensions_in_project($project)
6.x pm.drush.inc drush_pm_extensions_in_project($project)
7.x pm.drush.inc drush_pm_extensions_in_project($project)
4.x pm.drush.inc drush_pm_extensions_in_project($project)
5.x pm.drush.inc drush_pm_extensions_in_project($project)
master pm.drush.inc drush_pm_extensions_in_project($project)

Print out all extensions (modules/themes/profiles) found in specified project.

Find .info.yml files in the project path and identify modules, themes and profiles. It handles two kind of projects: drupal core/profiles and modules/themes. It does nothing with theme engine projects.

1 call to drush_pm_extensions_in_project()
drush_pm_download in commands/pm/download.pm.inc
Command callback. Download Drupal core or any project.

File

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

Code

function drush_pm_extensions_in_project($project) {
  // Mask for drush_scan_directory, to match .info.yml files.
  $mask = $project['drupal_version'][0] >= 8 ? '/(.*)\.info\.yml$/' : '/(.*)\.info$/';

  // Mask for drush_scan_directory, to avoid tests directories.
  $nomask = array('.', '..', 'CVS', 'tests');

  // Drupal core and profiles can contain modules, themes and profiles.
  if (in_array($project['project_type'], array('core', 'profile'))) {
    $found = array(
      'profile' => array(),
      'theme' => array(),
      'module' => array(),
    );
    // Find all of the .info files
    foreach (drush_scan_directory($project['full_project_path'], $mask, $nomask) as $filename => $info) {
      // Extract extension name from filename.
      $matches = array();
      preg_match($mask, $info->basename, $matches);
      $name = $matches[1];

      // Find the project type corresponding the .info file.
      // (Only drupal >=7.x has .info for .profile)
      $base = dirname($filename) . '/' . $name;
      if (is_file($base . '.module')) {
        $found['module'][] = $name;
      }
      else if (is_file($base . '.profile')) {
        $found['profile'][] = $name;
      }
      else {
        $found['theme'][] = $name;
      }
    }
    // Special case: find profiles for drupal < 7.x (no .info)
    if ($project['drupal_version'][0] < 7) {
      foreach (drush_find_profiles($project['full_project_path']) as $filename => $info) {
        $found['profile'][] = $info->name;
      }
    }
    // Log results.
    $msg = "Project !project contains:\n";
    $args = array('!project' => $project['name']);
    foreach (array_keys($found) as $type) {
      if ($count = count($found[$type])) {
        $msg .= " - !count_$type !type_$type: !found_$type\n";
        $args += array(
          "!count_$type" => $count,
          "!type_$type" => $type,
          "!found_$type" => implode(', ', $found[$type]),
        );
        if ($count > 1) {
          $args["!type_$type"] = $type . 's';
        }
      }
    }
    drush_log(dt($msg, $args), LogLevel::SUCCESS);
    drush_print_pipe(call_user_func_array('array_merge', array_values($found)));
  }
  // Modules and themes can only contain other extensions of the same type.
  elseif (in_array($project['project_type'], array('module', 'theme'))) {
    $found = array();
    foreach (drush_scan_directory($project['full_project_path'], $mask, $nomask) as $filename => $info) {
      // Extract extension name from filename.
      $matches = array();
      preg_match($mask, $info->basename, $matches);
      $found[] = $matches[1];
    }
    // If there is only one module / theme in the project, only print out
    // the message if is different than the project name.
    if (count($found) == 1) {
      if ($found[0] != $project['name']) {
        $msg = "Project !project contains a !type named !found.";
      }
    }
    // If there are multiple modules or themes in the project, list them all.
    else {
      $msg = "Project !project contains !count !types: !found.";
    }
    if (isset($msg)) {
      drush_print(dt($msg, array('!project' => $project['name'], '!count' => count($found), '!type' => $project['project_type'], '!found' => implode(', ', $found))));
    }
    drush_print_pipe($found);
    // Cache results.
    drush_pm_cache_project_extensions($project, $found);
  }
}