public static function Composer::getJsonFromClass in Markdown 8.2
Decodes the composer.json file from a given class and returns its data.
@internal
Parameters
string $className: The name of a class included via Composer's autoloader. Note: this is primarily used to help reverse engineer where Composer's vendor directory is without having to actually know where it is.
string $name: (Read-Only) The package name of composer.json, passed by reference.
string $file: (Read-Only) The complete path of composer.json, passed by reference.
Return value
array|void The JSON array of the composer.json file found; NULL otherwise.
Deprecated
in markdown:8.x-2.0 and is removed from markdown:4.0.0. No replacement.
See also
https://www.drupal.org/project/markdown/issues/3200476
1 call to Composer::getJsonFromClass()
- Composer::getVersionFromClass in src/
Util/ Composer.php - Retrieves the version based on a provided class name.
File
- src/
Util/ Composer.php, line 223
Class
- Composer
- Helper class used to deal with composer.
Namespace
Drupal\markdown\UtilCode
public static function getJsonFromClass($className, &$name = NULL, &$file = NULL) {
/** @var \Composer\Autoload\ClassLoader $autoloader */
$autoloader = \Drupal::service('class_loader');
if ($file = $autoloader
->findFile(ltrim(str_replace('\\\\', '\\', $className), '\\'))) {
$directory = realpath(dirname($file));
do {
$json = NULL;
if ($directory && is_dir($directory)) {
if ($json = static::getJson($directory, $name)) {
$file = "{$directory}/composer.json";
return $json;
}
$directory = dirname($directory);
}
} while ($directory);
}
}