public function InlineBlockDependencyCollector::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/ InlineBlockDependencyCollector.php, line 50
Class
- InlineBlockDependencyCollector
- Subscribes to layout builder dependency collection to extract inline block dependencies.
Namespace
Drupal\depcalc\EventSubscriber\LayoutBuilderComponentDepencyCollectorCode
public function onCalculateSectionComponentDependencies(SectionComponentDependenciesEvent $event) {
$component = $event
->getComponent();
$plugin = $component
->getPlugin();
if (!$plugin instanceof InlineBlock) {
return;
}
$revision_id = $plugin
->getConfiguration()['block_revision_id'];
$entity = $this->entityTypeManager
->getStorage('block_content')
->loadRevision($revision_id);
$event
->addEntityDependency($entity);
}