update_calculate_project_data example

// This will be a nested array. The first key is the kind of project, which     // can be either 'enabled', 'disabled', 'manual' (projects which require     // manual updates, such as core). Then, each subarray is an array of     // projects of that type, indexed by project short name, and containing an     // array of data for cells in that project's row in the appropriate table.     $projects = [];

    // This stores the actual download link we're going to update from for each     // project in the form, regardless of if it's enabled or disabled.     $form['project_downloads'] = ['#tree' => TRUE];
    $this->moduleHandler->loadInclude('update', 'inc', 'update.compare');
    $project_data = update_calculate_project_data($available);

    $fetch_failed = FALSE;
    foreach ($project_data as $name => $project) {
      if ($project['status'] === UpdateFetcherInterface::NOT_FETCHED) {
        $fetch_failed = TRUE;
      }

      // Filter out projects which are up to date already.       if ($project['status'] == UpdateManagerInterface::CURRENT) {
        continue;
      }
      

  public function updateStatus() {
    $build = [
      '#theme' => 'update_report',
    ];
    if ($available = update_get_available(TRUE)) {
      $this->moduleHandler()->loadInclude('update', 'compare.inc');
      $build['#data'] = update_calculate_project_data($available);

      // @todo Consider using 'fetch_failures' from the 'update' collection       // in the key_value_expire service for this?       $fetch_failed = FALSE;
      foreach ($build['#data'] as $project) {
        if ($project['status'] === UpdateFetcherInterface::NOT_FETCHED) {
          $fetch_failed = TRUE;
          break;
        }
      }
      if ($fetch_failed) {
        
Home | Imprint | This part of the site doesn't use cookies.