You are here

public function UpdateRecommender::getRecommendedRelease in Automatic Updates 8.2

Returns the recommended release of Drupal core.

Parameters

bool $refresh: (optional) Whether to fetch the latest information about available updates from drupal.org. This can be an expensive operation, so defaults to FALSE.

Return value

\Drupal\automatic_updates_9_3_shim\ProjectRelease|null A value object with information about the recommended release, or NULL if Drupal core is already up-to-date.

Throws

\LogicException If Drupal core is out of date and the recommended version of cannot be determined.

File

src/UpdateRecommender.php, line 53

Class

UpdateRecommender
Determines the recommended release of Drupal core to update to.

Namespace

Drupal\automatic_updates

Code

public function getRecommendedRelease(bool $refresh = FALSE) : ?ProjectRelease {
  $project = $this
    ->getProjectInfo($refresh);

  // If we're already up-to-date, there's nothing else we need to do.
  if ($project['status'] === UpdateManagerInterface::CURRENT) {
    return NULL;
  }
  elseif (empty($project['recommended'])) {
    throw new \LogicException('Drupal core is out of date, but the recommended version could not be determined.');
  }
  $recommended_version = $project['recommended'];
  return ProjectRelease::createFromArray($project['releases'][$recommended_version]);
}