You are here

public function ModuleDependencyCollector::onCalculateSectionComponentDependencies in Dependency Calculation 8

Calculates the entities referenced on Layout Builder components.

Parameters

\Drupal\depcalc\Event\SectionComponentDependenciesEvent $event: The dependency calculation event.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

src/EventSubscriber/LayoutBuilderComponentDepencyCollector/ModuleDependencyCollector.php, line 32

Class

ModuleDependencyCollector
Subscribes to layout builder dependency collection to extract module dependencies.

Namespace

Drupal\depcalc\EventSubscriber\LayoutBuilderComponentDepencyCollector

Code

public function onCalculateSectionComponentDependencies(SectionComponentDependenciesEvent $event) {
  $component = $event
    ->getComponent();
  $plugin = $component
    ->getPlugin();
  if ($plugin instanceof BlockPluginInterface) {
    $event
      ->addModuleDependency($plugin
      ->getConfiguration()['provider']);
  }
}