function YamlDiscovery::getDefinitions
Same name in other branches
- 9 core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php \Drupal\Core\Plugin\Discovery\YamlDiscovery::getDefinitions()
- 10 core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php \Drupal\Core\Plugin\Discovery\YamlDiscovery::getDefinitions()
- 11.x core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php \Drupal\Core\Plugin\Discovery\YamlDiscovery::getDefinitions()
Overrides DiscoveryTrait::getDefinitions
1 call to YamlDiscovery::getDefinitions()
- YamlDiscoveryDecorator::getDefinitions in core/
lib/ Drupal/ Core/ Plugin/ Discovery/ YamlDiscoveryDecorator.php
1 method overrides YamlDiscovery::getDefinitions()
- YamlDiscoveryDecorator::getDefinitions in core/
lib/ Drupal/ Core/ Plugin/ Discovery/ YamlDiscoveryDecorator.php
File
-
core/
lib/ Drupal/ Core/ Plugin/ Discovery/ YamlDiscovery.php, line 74
Class
- YamlDiscovery
- Allows YAML files to define plugin definitions.
Namespace
Drupal\Core\Plugin\DiscoveryCode
public function getDefinitions() {
$plugins = $this->discovery
->findAll();
// Flatten definitions into what's expected from plugins.
$definitions = [];
foreach ($plugins as $provider => $list) {
foreach ($list as $id => $definition) {
// Add TranslatableMarkup.
foreach ($this->translatableProperties as $property => $context_key) {
if (isset($definition[$property])) {
$options = [];
// Move the t() context from the definition to the translation
// wrapper.
if ($context_key && isset($definition[$context_key])) {
$options['context'] = $definition[$context_key];
unset($definition[$context_key]);
}
$definition[$property] = new TranslatableMarkup($definition[$property], [], $options);
}
}
// Add ID and provider.
$definitions[$id] = $definition + [
'provider' => $provider,
'id' => $id,
];
}
}
return $definitions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.