InfoHookDecorator.php in Drupal 8
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();
foreach (\Drupal::moduleHandler()
->getImplementations($this->hook) as $module) {
$function = $module . '_' . $this->hook;
$function($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. |