private function resolveDependencies(EntityManager $em, Job $job) { // If this job has failed, or has otherwise not succeeded, we need to set the // incoming dependencies to failed if that has not been done already. if (!$job->isFinished()) { /** @var JobRepository $repository */ $repository = $em->getRepository('JMS\\JobQueueBundle\\Entity\\Job'); foreach ($repository->findIncomingDependencies($job) as $incomingDep) { if ($incomingDep->isInFinalState()) { continue; } $finalState = Job::STATE_CANCELED; if ($job->isRunning()) { $finalState = Job::STATE_FAILED; } $repository->closeJob($incomingDep, $finalState); } } $em->getConnection()->executeUpdate("DELETE FROM jms_job_dependencies WHERE dest_job_id = :id", array('id' => $job->getId())); }