You are here

public function ProjectCollector::getPlan in Upgrade Status 8.3

Get the Drupal 9 plan for a project, either explicitly fetched or cached.

Parameters

string $project_machine_name: Machine name for project.

Return value

NULL|string Either NULL or the Drupal 9 plan for the project.

File

src/ProjectCollector.php, line 452

Class

ProjectCollector
Collects projects and their associated metadata collated for Upgrade Status.

Namespace

Drupal\upgrade_status

Code

public function getPlan(string $project_machine_name) {

  // Return explicitly fetched Drupal 9 plan if available.
  $result = $this
    ->getResults($project_machine_name);
  if (!empty($result) && !empty($result['plans'])) {
    return $result['plans'];
  }

  // Read our shipped snapshot of Drupal 9 plans to find this one.
  $file = fopen(drupal_get_path('module', 'upgrade_status') . '/project_plans.csv', 'r');
  while ($line = fgetcsv($file, 0, ";")) {
    if ($line[0] == $project_machine_name) {
      fclose($file);

      // Replace drupal.org link formatting with actual links.
      return preg_replace('!\\[#(\\d+)\\]!', '<a href="https://drupal.org/node/\\1">[#\\1]</a>', $line[1]);
    }
  }
  fclose($file);
  return NULL;
}