function AttributeBridgeDecorator::getDefinitions
Same name in other branches
- 11.x core/lib/Drupal/Component/Plugin/Discovery/AttributeBridgeDecorator.php \Drupal\Component\Plugin\Discovery\AttributeBridgeDecorator::getDefinitions()
Overrides DiscoveryTrait::getDefinitions
File
-
core/
lib/ Drupal/ Component/ Plugin/ Discovery/ AttributeBridgeDecorator.php, line 30
Class
- AttributeBridgeDecorator
- Ensures that all definitions are run through the attribute process.
Namespace
Drupal\Component\Plugin\DiscoveryCode
public function getDefinitions() {
$definitions = $this->decorated
->getDefinitions();
foreach ($definitions as $id => $definition) {
// Attribute constructors expect an array of values. If the definition is
// not an array, it usually means it has been processed already and can be
// ignored.
if (is_array($definition)) {
$class = $definition['class'] ?? NULL;
$provider = $definition['provider'] ?? NULL;
unset($definition['class'], $definition['provider']);
/** @var \Drupal\Component\Plugin\Attribute\AttributeInterface $attribute */
$attribute = new $this->pluginDefinitionAttributeName(...$definition);
if (isset($class)) {
$attribute->setClass($class);
}
if (isset($provider)) {
$attribute->setProvider($provider);
}
$definitions[$id] = $attribute->get();
}
}
return $definitions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.