public function Project::getSpecificRelease

8.0.x Project.php public Project::getSpecificRelease($version = NULL)
7.x Project.php public Project::getSpecificRelease($version = NULL)
master Project.php public Project::getSpecificRelease($version = NULL)

Returns the specific release that matches the request version.

Parameters

string $version: Version of the release to pick.

Return value

array|bool The release or FALSE if no version specified or no release found.

File

lib/Drush/UpdateService/Project.php, line 348

Namespace

Drush\UpdateService

Class

Project
Representation of a project's release info from the update service.

Code

public function getSpecificRelease($version = NULL) {
  if (!empty($version)) {
    $matches = array();
    // See if we only have a branch version.
    if (preg_match('/^\d+\.x-(\d+)$/', $version, $matches)) {
      $releases = $this->searchReleases('version_major', $matches[1]);
    }
    else {
      // In some cases, the request only says something like '7.x-3.x' but the
      // version strings include '-dev' on the end, so we need to append that
      // here for the xpath to match below.
      if (substr($version, -2) == '.x') {
        $version .= '-dev';
      }
      $releases = $this->searchReleases('version', $version);
    }
    if (empty($releases)) {
      return FALSE;
    }
    return self::getBestRelease($releases);
  }
  return array();
}