public function EntityFormDisplayDependencyCollector::onCalculateDependencies in Dependency Calculation 8
Calculates the associated entity form display.
Parameters
\Drupal\depcalc\Event\CalculateEntityDependenciesEvent $event: The dependency calculation event.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- src/
EventSubscriber/ DependencyCollector/ EntityFormDisplayDependencyCollector.php, line 50
Class
- EntityFormDisplayDependencyCollector
- Subscribes to dependency collection to extract the entity form display.
Namespace
Drupal\depcalc\EventSubscriber\DependencyCollectorCode
public function onCalculateDependencies(CalculateEntityDependenciesEvent $event) {
if ($event
->getEntity() instanceof ContentEntityInterface) {
$storage = $this->entityTypeManager
->getStorage('entity_form_display');
$entity = $event
->getEntity();
$ids = $this->entityTypeManager
->getStorage('entity_form_display')
->getQuery('AND')
->condition('status', TRUE)
->condition('targetEntityType', $entity
->getEntityTypeId())
->condition('bundle', $entity
->bundle())
->execute();
if ($ids) {
$displays = $storage
->loadMultiple($ids);
foreach ($displays as $display) {
$display_wrapper = new DependentEntityWrapper($display);
$local_dependencies = [];
$this
->mergeDependencies($display_wrapper, $event
->getStack(), $this
->getCalculator()
->calculateDependencies($display_wrapper, $event
->getStack(), $local_dependencies));
$event
->addDependency($display_wrapper);
}
}
}
}