class InfoHookDecorator
Same name in other branches
- 9 core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php \Drupal\Core\Plugin\Discovery\InfoHookDecorator
- 8.9.x core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php \Drupal\Core\Plugin\Discovery\InfoHookDecorator
- 10 core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php \Drupal\Core\Plugin\Discovery\InfoHookDecorator
Allows info hook implementations to enhance discovered plugin definitions.
Hierarchy
- class \Drupal\Core\Plugin\Discovery\InfoHookDecorator implements \Drupal\Component\Plugin\Discovery\DiscoveryInterface uses \Drupal\Component\Plugin\Discovery\DiscoveryTrait
Expanded class hierarchy of InfoHookDecorator
1 file declares its use of InfoHookDecorator
- ConfigMapperManager.php in core/
modules/ config_translation/ src/ ConfigMapperManager.php
File
-
core/
lib/ Drupal/ Core/ Plugin/ Discovery/ InfoHookDecorator.php, line 11
Namespace
Drupal\Core\Plugin\DiscoveryView source
class InfoHookDecorator implements DiscoveryInterface {
use DiscoveryTrait;
/**
* The Discovery object being decorated.
*
* @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
*/
protected $decorated;
/**
* The name of the info hook that will be implemented by this discovery instance.
*
* @var string
*/
protected $hook;
/**
* Constructs an InfoHookDecorator object.
*
* @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
* The object implementing DiscoveryInterface that is being decorated.
* @param string $hook
* The name of the info hook to be invoked by this discovery instance.
*/
public function __construct(DiscoveryInterface $decorated, $hook) {
$this->decorated = $decorated;
$this->hook = $hook;
}
/**
* {@inheritdoc}
*/
public function getDefinitions() {
$definitions = $this->decorated
->getDefinitions();
\Drupal::moduleHandler()->invokeAllWith($this->hook, function (callable $hook, string $module) use (&$definitions) {
$hook($definitions);
});
return $definitions;
}
/**
* Passes through all unknown calls onto the decorated object.
*/
public function __call($method, $args) {
return call_user_func_array([
$this->decorated,
$method,
], $args);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
DiscoveryTrait::doGetDefinition | protected | function | Gets a specific plugin definition. | ||
DiscoveryTrait::getDefinition | public | function | 3 | ||
DiscoveryTrait::hasDefinition | public | function | |||
InfoHookDecorator::$decorated | protected | property | The Discovery object being decorated. | ||
InfoHookDecorator::$hook | protected | property | The name of the info hook that will be implemented by this discovery instance. | ||
InfoHookDecorator::getDefinitions | public | function | Gets the definition of all plugins for this type. | Overrides DiscoveryTrait::getDefinitions | |
InfoHookDecorator::__call | public | function | Passes through all unknown calls onto the decorated object. | ||
InfoHookDecorator::__construct | public | function | Constructs an InfoHookDecorator object. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.