Same filename and directory in other branches
- 8.9.x core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php
- 9 core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php
Namespace
Drupal\Core\Plugin\Discovery
File
core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php
View source
<?php
namespace Drupal\Core\Plugin\Discovery;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
use Drupal\Core\Extension\ModuleHandlerInterface;
class HookDiscovery implements DiscoveryInterface {
use DiscoveryTrait;
protected $hook;
protected $moduleHandler;
public function __construct(ModuleHandlerInterface $module_handler, $hook) {
$this->moduleHandler = $module_handler;
$this->hook = $hook;
}
public function getDefinitions() {
$definitions = [];
$this->moduleHandler
->invokeAllWith($this->hook, function (callable $hook, string $module) use (&$definitions) {
$module_definitions = $hook();
foreach ($module_definitions as $plugin_id => $definition) {
$definition['provider'] = $module;
$definitions[$plugin_id] = $definition;
}
});
return $definitions;
}
}
Classes