protected function ComposerPackage::detectVersion in Markdown 8.2
Detects the installed version of a Composer package.
Return value
string|void The detected version of the Composer package or NULL if not enabled.
Overrides InstallableLibrary::detectVersion
File
- src/
Annotation/ ComposerPackage.php, line 27
Class
- ComposerPackage
- Annotation for providing an installable library via Composer.
Namespace
Drupal\markdown\AnnotationCode
protected function detectVersion() {
$id = $this
->getId();
// Composer 1 support.
// @todo Remove in 4.0.0.
// @see https://www.drupal.org/project/markdown/issues/3200476
if (!class_exists('\\Composer\\InstalledVersions')) {
return Composer::getInstalledVersion($id) ?: Composer::getVersionFromClass($this->object);
}
// Composer 2+ runtime installed versions support.
// @see https://getcomposer.org/doc/07-runtime.md#knowing-the-version-of-package-x
if (InstalledVersions::isInstalled($id)) {
return InstalledVersions::getPrettyVersion($id);
}
}