protected function ComposerJsonSource::getDecodedJson in PatchInfo 8.2
Gets decoded JSON from a JSON file.
Parameters
string $path: Path to JSON file.
string $file: JSON file name.
Return value
mixed Parsed JSON.
1 call to ComposerJsonSource::getDecodedJson()
- ComposerJsonSource::parseComposerFile in modules/
patchinfo_source_composer/ src/ Plugin/ PatchInfo/ Source/ ComposerJsonSource.php - Parses composer.json within a given path for patches.
File
- modules/
patchinfo_source_composer/ src/ Plugin/ PatchInfo/ Source/ ComposerJsonSource.php, line 175
Class
- ComposerJsonSource
- Gathers patch information from composer.json files.
Namespace
Drupal\patchinfo_source_composer\Plugin\patchinfo\sourceCode
protected function getDecodedJson(string $path, string $file) {
$return = [];
if (!file_exists($path . '/' . $file)) {
return $return;
}
if (!is_readable($path . '/' . $file)) {
$this->loggerFactory
->get('patchinfo_source_composer')
->warning($this
->t('Can not read @path/@file. Check your file permissions.', [
'@path' => $path,
'@file' => $file,
]));
return $return;
}
$content = file_get_contents($path . '/' . $file);
if ($content === FALSE) {
$this->loggerFactory
->get('patchinfo_source_composer')
->warning($this
->t('Can not get contents from @path/@file.', [
'@path' => $path,
'@file' => $file,
]));
return $return;
}
$config = json_decode($content, TRUE);
if ($config === NULL) {
$this->loggerFactory
->get('patchinfo_source_composer')
->warning($this
->t('Unable to parse @path/@file. Check your JSON syntax.', [
'@path' => $path,
'@file' => $file,
]));
return $return;
}
return $config;
}