trait CalculateDependenciesEventDispatcherTrait in Dependency Calculation 8
Provides a method to dispatch calculate dependencies event.
Hierarchy
- trait \Drupal\Tests\depcalc\Kernel\EventSubscriber\DependencyCollector\CalculateDependenciesEventDispatcherTrait
File
- tests/
src/ Kernel/ EventSubscriber/ DependencyCollector/ CalculateDependenciesEventDispatcherTrait.php, line 14
Namespace
Drupal\Tests\depcalc\Kernel\EventSubscriber\DependencyCollectorView source
trait CalculateDependenciesEventDispatcherTrait {
/**
* Dispatches dependency calculation event.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to use in the event.
*
* @return \Drupal\depcalc\Event\CalculateEntityDependenciesEvent
* The event.
*
* @throws \Exception
*/
protected function dispatchCalculateDependencies(EntityInterface $entity) : CalculateEntityDependenciesEvent {
$wrapper = new DependentEntityWrapper($entity);
$dependencies = new DependencyStack();
$event = new CalculateEntityDependenciesEvent($wrapper, $dependencies);
$this->container
->get('event_dispatcher')
->dispatch(DependencyCalculatorEvents::CALCULATE_DEPENDENCIES, $event);
return $event;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CalculateDependenciesEventDispatcherTrait:: |
protected | function | Dispatches dependency calculation event. |