class LayoutBuilderEntityViewDisplayDependencyCollector in Dependency Calculation 8
Subscribes to dependency collection to extract entities referenced on Layout Builder components.
Hierarchy
- class \Drupal\depcalc\EventSubscriber\DependencyCollector\BaseDependencyCollector implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\depcalc\EventSubscriber\LayoutBuilderComponentDepencyCollector\LayoutBuilderDependencyCollectorBase
- class \Drupal\depcalc\EventSubscriber\DependencyCollector\LayoutBuilderEntityViewDisplayDependencyCollector
- class \Drupal\depcalc\EventSubscriber\LayoutBuilderComponentDepencyCollector\LayoutBuilderDependencyCollectorBase
Expanded class hierarchy of LayoutBuilderEntityViewDisplayDependencyCollector
1 string reference to 'LayoutBuilderEntityViewDisplayDependencyCollector'
1 service uses LayoutBuilderEntityViewDisplayDependencyCollector
File
- src/
EventSubscriber/ DependencyCollector/ LayoutBuilderEntityViewDisplayDependencyCollector.php, line 12
Namespace
Drupal\depcalc\EventSubscriber\DependencyCollectorView source
class LayoutBuilderEntityViewDisplayDependencyCollector extends LayoutBuilderDependencyCollectorBase {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[DependencyCalculatorEvents::CALCULATE_DEPENDENCIES][] = [
'onCalculateDependencies',
];
return $events;
}
/**
* Calculates the entities referenced in Layout Builder components.
*
* @param \Drupal\depcalc\Event\CalculateEntityDependenciesEvent $event
* The dependency calculation event.
*
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function onCalculateDependencies(CalculateEntityDependenciesEvent $event) {
if (!$this->layoutPluginManager) {
return;
}
/** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $entity */
$entity = $event
->getEntity();
if ($entity
->getEntityTypeId() !== 'entity_view_display') {
return;
}
$sections = $entity
->getThirdPartySetting('layout_builder', 'sections') ?? [];
foreach ($sections as $section) {
$this
->addSectionDependencies($event, $section);
$this
->addComponentDependencies($event, $section
->getComponents());
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BaseDependencyCollector:: |
protected | function | Gets the dependency calculator. | |
BaseDependencyCollector:: |
protected | function | Properly adds dependencies and their modules to a wrapper object. | |
LayoutBuilderDependencyCollectorBase:: |
protected | property | The event dispatcher. | |
LayoutBuilderDependencyCollectorBase:: |
protected | property | The layout plugin manager. | |
LayoutBuilderDependencyCollectorBase:: |
protected | function | Adds dependencies from components. | |
LayoutBuilderDependencyCollectorBase:: |
protected | function | Adds entity dependencies from this layout builder field to this event dependencies. | |
LayoutBuilderDependencyCollectorBase:: |
protected | function | Set module dependencies to the event. | |
LayoutBuilderDependencyCollectorBase:: |
public | function | The LayoutBuilderDependencyCollectorBase constructor. | |
LayoutBuilderEntityViewDisplayDependencyCollector:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
LayoutBuilderEntityViewDisplayDependencyCollector:: |
public | function | Calculates the entities referenced in Layout Builder components. |