public static function JobItem::preDelete

File

src/Entity/JobItem.php, line 202

Class

JobItem
Entity class for the tmgmt_job_item entity.

Namespace

Drupal\tmgmt\Entity

Code

public static function preDelete(EntityStorageInterface $storage, array $entities) {

  // We need to check whether the state of the job is affected by this
  // deletion.
  foreach ($entities as $entity) {
    if ($job = $entity
      ->getJob()) {

      // We only care for active jobs.
      if ($job
        ->isActive() && tmgmt_job_check_finished($job
        ->id())) {

        // Mark the job as finished.
        $job
          ->finished();
      }
    }
  }
  parent::preDelete($storage, $entities);
}