protected function ComposerJsonSource::parseComposerFile in PatchInfo 8.2
Parses composer.json within a given path for patches.
Parameters
string $path: A path from the local filesystem from where to fetch composer.json.
Return value
array An array of patch information keyed by composer project name. The patch information is an array with an info key and a source key. The info key is a string with the url of the patch file followed by a space and the patch description. The source key is the path to the composer.json file that contained the patch information or link to the external patch file.
1 call to ComposerJsonSource::parseComposerFile()
- ComposerJsonSource::getPatches in modules/
patchinfo_source_composer/ src/ Plugin/ PatchInfo/ Source/ ComposerJsonSource.php - Gets patch information for a module from a patch source.
File
- modules/
patchinfo_source_composer/ src/ Plugin/ PatchInfo/ Source/ ComposerJsonSource.php, line 117
Class
- ComposerJsonSource
- Gathers patch information from composer.json files.
Namespace
Drupal\patchinfo_source_composer\Plugin\patchinfo\sourceCode
protected function parseComposerFile(string $path) {
$return = [];
// Try to prevent triggering open basedir restrictions.
if (stream_resolve_include_path($path . DIRECTORY_SEPARATOR . 'composer.json') === FALSE) {
return $return;
}
$path = $this->fileSystem
->realpath($path);
$config = $this
->getDecodedJson($path, 'composer.json');
$patches = [];
if (!empty($config['extra']['patches'])) {
$patches = $config['extra']['patches'];
}
elseif (!empty($config['extra']['patches-file'])) {
$patchfile = $this
->getDecodedJson($path, $config['extra']['patches-file']);
if (!empty($patchfile['patches'])) {
$patches = $patchfile['patches'];
}
}
foreach ($patches as $project => $project_patches) {
if (strpos($project, 'drupal/') !== 0) {
// Only handle Drupal projects.
continue;
}
// Generate Drupal project name from composer project name.
$project = str_replace('drupal/', '', $project);
if ($project == 'core' || $project == 'drupal') {
$project = 'system';
}
foreach ($project_patches as $description => $url) {
$info = $url . ' ' . $description;
$return[$project][] = [
'info' => trim($info),
'source' => $path . '/composer.json',
];
}
}
return $return;
}