InfoHookDecorator.php in Drupal 10
File
core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php
View source
<?php
namespace Drupal\Core\Plugin\Discovery;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
class InfoHookDecorator implements DiscoveryInterface {
use DiscoveryTrait;
protected $decorated;
protected $hook;
public function __construct(DiscoveryInterface $decorated, $hook) {
$this->decorated = $decorated;
$this->hook = $hook;
}
public function getDefinitions() {
$definitions = $this->decorated
->getDefinitions();
\Drupal::moduleHandler()
->invokeAllWith($this->hook, function (callable $hook, string $module) use (&$definitions) {
$hook($definitions);
});
return $definitions;
}
public function __call($method, $args) {
return call_user_func_array([
$this->decorated,
$method,
], $args);
}
}
Classes
Name |
Description |
InfoHookDecorator |
Allows info hook implementations to enhance discovered plugin definitions. |