You are here

public function PeclExtension::getAvailableVersions in Markdown 8.2

Retrieves the available versions of the library.

Note: this will likely make an HTTP request.

Return value

string[] The available versions.

Overrides InstallableLibrary::getAvailableVersions

File

src/Annotation/PeclExtension.php, line 67

Class

PeclExtension
PeclExtension Annotation.

Namespace

Drupal\markdown\Annotation

Code

public function getAvailableVersions() {
  if (!isset($this->availableVersions)) {
    $this->availableVersions = [];

    // @see https://github.com/php/web-pecl/blob/e98cb34ebcb26b75b4001d1b3458afdad6ba6f83/src/Rest.php#L519-L520
    if (($name = $this
      ->getName()) && ($data = $this
      ->requestXml(sprintf('https://pecl.php.net/rest/r/%s/allreleases.xml', $name), TRUE)) && !empty($data['r'])) {
      $this->availableVersions = array_column($data['r'], 'v');
    }
  }
  return $this->availableVersions;
}