class ModuleDependencyCollector in Dependency Calculation 8
Subscribes to layout builder dependency collection to extract module dependencies.
Hierarchy
- class \Drupal\depcalc\EventSubscriber\LayoutBuilderComponentDepencyCollector\ModuleDependencyCollector implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ModuleDependencyCollector
1 string reference to 'ModuleDependencyCollector'
1 service uses ModuleDependencyCollector
File
- src/
EventSubscriber/ LayoutBuilderComponentDepencyCollector/ ModuleDependencyCollector.php, line 13
Namespace
Drupal\depcalc\EventSubscriber\LayoutBuilderComponentDepencyCollectorView source
class ModuleDependencyCollector implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[DependencyCalculatorEvents::SECTION_COMPONENT_DEPENDENCIES_EVENT][] = [
'onCalculateSectionComponentDependencies',
];
return $events;
}
/**
* Calculates the entities referenced on Layout Builder components.
*
* @param \Drupal\depcalc\Event\SectionComponentDependenciesEvent $event
* The dependency calculation event.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function onCalculateSectionComponentDependencies(SectionComponentDependenciesEvent $event) {
$component = $event
->getComponent();
$plugin = $component
->getPlugin();
if ($plugin instanceof BlockPluginInterface) {
$event
->addModuleDependency($plugin
->getConfiguration()['provider']);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ModuleDependencyCollector:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ModuleDependencyCollector:: |
public | function | Calculates the entities referenced on Layout Builder components. |