class AnnotationBridgeDecorator in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotationBridgeDecorator.php \Drupal\Component\Annotation\Plugin\Discovery\AnnotationBridgeDecorator
Ensures that all definitions are run through the annotation process.
Hierarchy
- class \Drupal\Component\Annotation\Plugin\Discovery\AnnotationBridgeDecorator implements DiscoveryInterface uses DiscoveryTrait
Expanded class hierarchy of AnnotationBridgeDecorator
2 files declare their use of AnnotationBridgeDecorator
- AnnotationBridgeDecoratorTest.php in core/
tests/ Drupal/ Tests/ Component/ Annotation/ Plugin/ Discovery/ AnnotationBridgeDecoratorTest.php - LayoutPluginManager.php in core/
lib/ Drupal/ Core/ Layout/ LayoutPluginManager.php
File
- core/
lib/ Drupal/ Component/ Annotation/ Plugin/ Discovery/ AnnotationBridgeDecorator.php, line 11
Namespace
Drupal\Component\Annotation\Plugin\DiscoveryView source
class AnnotationBridgeDecorator implements DiscoveryInterface {
use DiscoveryTrait;
/**
* The decorated plugin discovery.
*
* @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
*/
protected $decorated;
/**
* The name of the annotation that contains the plugin definition.
*
* @var string|null
*/
protected $pluginDefinitionAnnotationName;
/**
* ObjectDefinitionDiscoveryDecorator constructor.
*
* @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
* The discovery object that is being decorated.
* @param string $plugin_definition_annotation_name
* The name of the annotation that contains the plugin definition. The class
* corresponding to this name must implement
* \Drupal\Component\Annotation\AnnotationInterface.
*/
public function __construct(DiscoveryInterface $decorated, $plugin_definition_annotation_name) {
$this->decorated = $decorated;
$this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
}
/**
* {@inheritdoc}
*/
public function getDefinitions() {
$definitions = $this->decorated
->getDefinitions();
foreach ($definitions as $id => $definition) {
// Annotation 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)) {
$definitions[$id] = (new $this->pluginDefinitionAnnotationName($definition))
->get();
}
}
return $definitions;
}
/**
* Passes through all unknown calls onto the decorated object.
*
* @param string $method
* The method to call on the decorated plugin discovery.
* @param array $args
* The arguments to send to the method.
*
* @return mixed
* The method result.
*/
public function __call($method, $args) {
return call_user_func_array([
$this->decorated,
$method,
], $args);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AnnotationBridgeDecorator:: |
protected | property | The decorated plugin discovery. | |
AnnotationBridgeDecorator:: |
protected | property | The name of the annotation that contains the plugin definition. | |
AnnotationBridgeDecorator:: |
public | function |
Gets the definition of all plugins for this type. Overrides DiscoveryTrait:: |
|
AnnotationBridgeDecorator:: |
public | function | Passes through all unknown calls onto the decorated object. | |
AnnotationBridgeDecorator:: |
public | function | ObjectDefinitionDiscoveryDecorator constructor. | |
DiscoveryTrait:: |
protected | function | Gets a specific plugin definition. | |
DiscoveryTrait:: |
public | function | 3 | |
DiscoveryTrait:: |
public | function |