You are here

function composer_manager_required_packages in Composer Manager 7

Same name and namespace in other branches
  1. 6.2 composer_manager.admin.inc \composer_manager_required_packages()
  2. 6 composer_manager.admin.inc \composer_manager_required_packages()
  3. 7.2 composer_manager.admin.inc \composer_manager_required_packages()

Returns the packages, versions, and the modules that require them in the composer.json files contained in contributed modules.

Return value

array

2 calls to composer_manager_required_packages()
composer_manager_packages_page in ./composer_manager.admin.inc
Page callback; Shows the status of all packages required by contrib.
composer_manager_packages_to_install in ./composer_manager.install
Returns a list of packages that need to be installed.

File

./composer_manager.admin.inc, line 367
Administrative settings for the Composer Manager module.

Code

function composer_manager_required_packages() {
  $required =& drupal_static(__FUNCTION__, NULL);
  if (NULL === $required) {
    require_once __DIR__ . '/composer_manager.writer.inc';

    // Gathers package versions.
    $required = array();
    $data = composer_manager_fetch_data();
    foreach ($data as $module => $json) {
      if (isset($json['require'])) {
        foreach ($json['require'] as $package => $version) {
          $pattern = '@^[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]+$@';
          if (preg_match($pattern, $package)) {
            if (!isset($required[$package])) {
              $required[$package][$version] = array();
            }
            $required[$package][$version][] = $module;
          }
        }
      }
    }
    ksort($required);
  }
  return $required;
}