class HookDiscovery in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php \Drupal\Core\Plugin\Discovery\HookDiscovery
Provides a hook-based plugin discovery class.
Hierarchy
- class \Drupal\Core\Plugin\Discovery\HookDiscovery implements DiscoveryInterface uses DiscoveryTrait
Expanded class hierarchy of HookDiscovery
1 file declares its use of HookDiscovery
- HookDiscoveryTest.php in core/
tests/ Drupal/ Tests/ Core/ Plugin/ Discovery/ HookDiscoveryTest.php - Contains \Drupal\Tests\Core\Plugin\Discovery\HookDiscoveryTest.
File
- core/
lib/ Drupal/ Core/ Plugin/ Discovery/ HookDiscovery.php, line 17 - Contains \Drupal\Core\Plugin\Discovery\HookDiscovery.
Namespace
Drupal\Core\Plugin\DiscoveryView source
class HookDiscovery implements DiscoveryInterface {
use DiscoveryTrait;
/**
* The name of the hook that will be implemented by this discovery instance.
*
* @var string
*/
protected $hook;
/**
* The module handler used to find and execute the plugin hook.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Constructs a Drupal\Core\Plugin\Discovery\HookDiscovery object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param string $hook
* The Drupal hook that a module can implement in order to interface to
* this discovery class.
*/
function __construct(ModuleHandlerInterface $module_handler, $hook) {
$this->moduleHandler = $module_handler;
$this->hook = $hook;
}
/**
* {@inheritdoc}
*/
public function getDefinitions() {
$definitions = array();
foreach ($this->moduleHandler
->getImplementations($this->hook) as $module) {
$result = $this->moduleHandler
->invoke($module, $this->hook);
foreach ($result as $plugin_id => $definition) {
$definition['provider'] = $module;
$definitions[$plugin_id] = $definition;
}
}
return $definitions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DiscoveryTrait:: |
protected | function | Gets a specific plugin definition. | |
DiscoveryTrait:: |
public | function | 3 | |
DiscoveryTrait:: |
public | function | ||
HookDiscovery:: |
protected | property | The name of the hook that will be implemented by this discovery instance. | |
HookDiscovery:: |
protected | property | The module handler used to find and execute the plugin hook. | |
HookDiscovery:: |
public | function |
Gets the definition of all plugins for this type. Overrides DiscoveryTrait:: |
|
HookDiscovery:: |
function | Constructs a Drupal\Core\Plugin\Discovery\HookDiscovery object. |