class InfoYmlSource in PatchInfo 8.2
Gathers patch information from info.yml files.
This source plugin will read patch information from .info.yml files of themes or modules.
In the *.info.yml file of a patched theme or module, add a new list like the one shown below:
patches:
-'https://www.drupal.org/node/1739718 Issue 1739718, Patch #32';
You can add multiple entries to the list. Each entry should start with the URL of the issue or patch followed by any kind of information about the patch. The URL is optional.
You can use any URL or description, that is convenient to you.
If you are patching a submodule, you may add the patch entry to the *.info.yml file of the submodule.
Plugin annotation
@PatchInfoSource(
id = "patchinfo_info_yml",
label = @Translation("info.yml", context = "PatchInfoSource"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\patchinfo\PatchInfoSourceBase implements PatchInfoSourceInterface uses StringTranslationTrait
- class \Drupal\patchinfo_source_info\Plugin\patchinfo\source\InfoYmlSource
- class \Drupal\patchinfo\PatchInfoSourceBase implements PatchInfoSourceInterface uses StringTranslationTrait
Expanded class hierarchy of InfoYmlSource
File
- modules/
patchinfo_source_info/ src/ Plugin/ PatchInfo/ Source/ InfoYmlSource.php, line 36
Namespace
Drupal\patchinfo_source_info\Plugin\patchinfo\sourceView source
class InfoYmlSource extends PatchInfoSourceBase {
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InfoYmlSource:: |
public | function |
Gets patch information for a module from a patch source. Overrides PatchInfoSourceBase:: |
|
PatchInfoSourceBase:: |
protected | property | The logger factory. | |
PatchInfoSourceBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
PatchInfoSourceBase:: |
public | function |
Gets the plugin label. Overrides PatchInfoSourceInterface:: |
|
PatchInfoSourceBase:: |
public | function |
Constructs a PatchInfoSourceBase object. Overrides PluginBase:: |
1 |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |