public function InfoYmlSource::getPatches in PatchInfo 8.2
Gets patch information for a module from a patch source.
$return['ctools'] = [
0 => [
'info' => 'https://www.drupal.org/node/1739718 Issue 1739718, Patch #32',
'source' => 'modules/contrib/ctools/ctools.info.yml',
],
];
Parameters
array $info: The parsed .info.yml file contents of the module to get patches for.
\Drupal\Core\Extension\Extension $file: Full information about the module or theme to get patches for.
string $type: Either 'module' or 'theme'.
Return value
array An array of patch information arrays keyed by machine-readable name of target module. The patch information array for each target module is an integer-keyed array of patch information. The patch information is an array with two keys, 'info' and 'source'. The 'info' key contains the patch information, i.e. a string with a URL followed by any patch description. The URL is optional. 'source' is a string, that contains a human-readable source information for the patch information.
Overrides PatchInfoSourceBase::getPatches
File
- modules/
patchinfo_source_info/ src/ Plugin/ PatchInfo/ Source/ InfoYmlSource.php, line 41
Class
- InfoYmlSource
- Gathers patch information from info.yml files.
Namespace
Drupal\patchinfo_source_info\Plugin\patchinfo\sourceCode
public function getPatches(array $info, Extension $file, string $type) {
$return = [];
if (!in_array($type, [
'module',
'theme',
])) {
return $return;
}
if (!isset($info['patches']) || !is_array($info['patches']) || count($info['patches']) < 1) {
return $return;
}
foreach ($info['patches'] as $key => $info) {
// If a colon is used in the patch description and the user didn't enclose
// the patch entry in single quotes as shown in the README file, the entry
// is interpreted by the YAML parser as an array in older versions of
// Drupal. Newer versions of Drupal will fail with a YAML parser exception
// that we can not reasonably prevent, but to prevent possible database
// exceptions in older versions of Drupal, we replace the actual
// information with a warning message instructing the user to check the
// .info.yml file syntax and log the error as well.
if (is_array($info)) {
$this->loggerFactory
->get('patchinfo_source_info')
->warning($this
->t('Malformed patch entry detected in @module.info.yml at index @key. Check the syntax or your info.yml file! In most cases, this may be fixed by enclosing the patch entry in single or double quotes.', [
'@module' => $file
->getName(),
'@key' => $key,
]));
$info = $this
->t('Malformed patch entry detected. Check the syntax of your info.yml file! In most cases, this may be fixed by enclosing the patch entry in single or double quotes.');
}
$return[$file
->getName()][] = [
'info' => $info,
'source' => $file
->getPath() . '/' . $file
->getName() . '.info.yml',
];
}
return $return;
}