You are here

public function ComposerPackage::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/ComposerPackage.php, line 47

Class

ComposerPackage
Annotation for providing an installable library via Composer.

Namespace

Drupal\markdown\Annotation

Code

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

    // To ensure we have the latest versions at all times, use the
    // https://repo.packagist.org/p/[vendor]/[package].json URL which are
    // static files and not cached.
    $json = $this
      ->requestJson(sprintf('https://repo.packagist.org/p/%s.json', $id));
    if (!empty($json['packages'][$id])) {
      $this->availableVersions = array_keys($json['packages'][$id]);
    }
  }
  return $this->availableVersions;
}