function ProjectInfo::getAvailableProjects

Same name and namespace in other branches
  1. main core/modules/package_manager/src/ProjectInfo.php \Drupal\package_manager\ProjectInfo::getAvailableProjects()

Gets the available projects.

Return value

array The available projects keyed by project machine name in the format returned by \Drupal\update\UpdateManagerInterface::getAvailable(). If the project specified in ::name is not returned from \Drupal\update\UpdateManagerInterface::getAvailable() this project will be explicitly fetched and added the return value of this function.

See also

\Drupal\update\UpdateManagerInterface::getAvailable()

1 call to ProjectInfo::getAvailableProjects()
ProjectInfo::getProjectInfo in core/modules/package_manager/src/ProjectInfo.php
Returns up-to-date project information.

File

core/modules/package_manager/src/ProjectInfo.php, line 180

Class

ProjectInfo
Retrieves project information from the Update Status module.

Namespace

Drupal\package_manager

Code

private function getAvailableProjects() : array {
  $available_projects = \Drupal::service(UpdateManagerInterface::class)->getAvailable(TRUE);
  // \Drupal\update\UpdateManagerInterface::getAvailable() will only return
  // projects that are in the active codebase. If the project specified by
  // ::name is not returned in $available_projects, it means it is not in the
  // active codebase, therefore we will retrieve the project information from
  // Package Manager's own update processor service.
  if (!isset($available_projects[$this->name])) {
    /** @var \Drupal\package_manager\PackageManagerUpdateProcessor $update_processor */
    $update_processor = \Drupal::service(PackageManagerUpdateProcessor::class);
    if ($project_data = $update_processor->getProjectData($this->name)) {
      $available_projects[$this->name] = $project_data;
    }
  }
  return $available_projects;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.