3 namespace Drupal\Core\Plugin\Discovery;
5 use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
6 use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
9 * Allows info hook implementations to enhance discovered plugin definitions.
11 class InfoHookDecorator implements DiscoveryInterface {
16 * The Discovery object being decorated.
18 * @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
23 * The name of the info hook that will be implemented by this discovery instance.
30 * Constructs a InfoHookDecorator object.
32 * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
33 * The object implementing DiscoveryInterface that is being decorated.
35 * The name of the info hook to be invoked by this discovery instance.
37 public function __construct(DiscoveryInterface $decorated, $hook) {
38 $this->decorated = $decorated;
45 public function getDefinitions() {
46 $definitions = $this->decorated->getDefinitions();
47 foreach (\Drupal::moduleHandler()->getImplementations($this->hook) as $module) {
48 $function = $module . '_' . $this->hook;
49 $function($definitions);
55 * Passes through all unknown calls onto the decorated object.
57 public function __call($method, $args) {
58 return call_user_func_array([$this->decorated, $method], $args);