You are here

public function PeclExtension::getVersionUrl in Markdown 8.2

Retrieves the version as a URL.

Parameters

string $version: A specific version to retrieve a URL for. If not specified, it will default to the currently installed version.

array $options: Optional. Options to pass to the creation of the URL object.

Return value

\Drupal\Core\Url|false A specific version URL, if set; FALSE otherwise.

Overrides InstallableLibrary::getVersionUrl

File

src/Annotation/PeclExtension.php, line 147

Class

PeclExtension
PeclExtension Annotation.

Namespace

Drupal\markdown\Annotation

Code

public function getVersionUrl($version = NULL, array $options = []) {
  if (!isset($version)) {
    $version = $this->version ?: '';
  }
  if (!isset($this->versionUrls[$version])) {
    $this->versionUrls[$version] = FALSE;
    if ($this
      ->isKnownVersion($version) && !$this
      ->isDev($version) && ($name = $this
      ->getName())) {
      if (!isset($options['attributes']['target'])) {
        $options['attributes']['target'] = '_blank';
      }
      $this->versionUrls[$version] = Url::fromUri(sprintf('https://pecl.php.net/package/%s/%s', $name, $version), $options);
    }
  }
  return $this->versionUrls[$version];
}