You are here

public function WorkflowCollector::onCalculateDependencies in Dependency Calculation 8

Calculates the associated workflows.

Parameters

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

Throws

\Exception

File

src/EventSubscriber/DependencyCollector/WorkflowCollector.php, line 49

Class

WorkflowCollector
Subscribes to dependency collection to extract the entity form display.

Namespace

Drupal\depcalc\EventSubscriber\DependencyCollector

Code

public function onCalculateDependencies(CalculateEntityDependenciesEvent $event) {
  if (!$this->moderationInfo) {
    return;
  }
  if ($event
    ->getEntity() instanceof ContentEntityInterface) {
    $workflow = $this->moderationInfo
      ->getWorkflowForEntity($event
      ->getEntity());
    if ($workflow) {
      $wrapper = new DependentEntityWrapper($workflow);
      $local_dependencies = [];
      $this
        ->mergeDependencies($wrapper, $event
        ->getStack(), $this
        ->getCalculator()
        ->calculateDependencies($wrapper, $event
        ->getStack(), $local_dependencies));
      $event
        ->addDependency($wrapper);
    }
  }
}