diff --git a/Command/CleanUpCommand.php b/Command/CleanUpCommand.php index cc810731..5133bbfb 100644 --- a/Command/CleanUpCommand.php +++ b/Command/CleanUpCommand.php @@ -4,7 +4,7 @@ use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\DBAL\Connection; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use JMS\JobQueueBundle\Entity\Job; use JMS\JobQueueBundle\Entity\Repository\JobManager; use Symfony\Component\Console\Command\Command; @@ -39,7 +39,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { - /** @var EntityManager $em */ + /** @var EntityManagerInterface $em */ $em = $this->registry->getManagerForClass(Job::class); $con = $em->getConnection(); @@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->collectStaleJobs($em); } - private function collectStaleJobs(EntityManager $em) + private function collectStaleJobs(EntityManagerInterface $em) { foreach ($this->findStaleJobs($em) as $job) { if ($job->isRetried()) { @@ -61,7 +61,7 @@ private function collectStaleJobs(EntityManager $em) /** * @return Job[] */ - private function findStaleJobs(EntityManager $em) + private function findStaleJobs(EntityManagerInterface $em) { $excludedIds = array(-1); @@ -86,7 +86,7 @@ private function findStaleJobs(EntityManager $em) } while ($job !== null); } - private function cleanUpExpiredJobs(EntityManager $em, Connection $con, InputInterface $input) + private function cleanUpExpiredJobs(EntityManagerInterface $em, Connection $con, InputInterface $input) { $incomingDepsSql = $con->getDatabasePlatform()->modifyLimitQuery("SELECT 1 FROM jms_job_dependencies WHERE dest_job_id = :id", 1); @@ -116,7 +116,7 @@ private function cleanUpExpiredJobs(EntityManager $em, Connection $con, InputInt $em->flush(); } - private function resolveDependencies(EntityManager $em, Job $job) + private function resolveDependencies(EntityManagerInterface $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. @@ -138,7 +138,7 @@ private function resolveDependencies(EntityManager $em, Job $job) $em->getConnection()->executeUpdate("DELETE FROM jms_job_dependencies WHERE dest_job_id = :id", array('id' => $job->getId())); } - private function findExpiredJobs(EntityManager $em, InputInterface $input) + private function findExpiredJobs(EntityManagerInterface $em, InputInterface $input) { $succeededJobs = function(array $excludedIds) use ($em, $input) { return $em->createQuery("SELECT j FROM JMSJobQueueBundle:Job j WHERE j.closedAt < :maxRetentionTime AND j.originalJob IS NULL AND j.state = :succeeded AND j.id NOT IN (:excludedIds)") diff --git a/Command/MarkJobIncompleteCommand.php b/Command/MarkJobIncompleteCommand.php index 032b0cd8..59666cf3 100644 --- a/Command/MarkJobIncompleteCommand.php +++ b/Command/MarkJobIncompleteCommand.php @@ -3,7 +3,7 @@ namespace JMS\JobQueueBundle\Command; use Doctrine\Common\Persistence\ManagerRegistry; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use JMS\JobQueueBundle\Entity\Job; use Symfony\Component\Console\Command\Command; use JMS\JobQueueBundle\Entity\Repository\JobManager; @@ -36,7 +36,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { - /** @var EntityManager $em */ + /** @var EntityManagerInterface $em */ $em = $this->registry->getManagerForClass(Job::class); /** @var Job|null $job */ diff --git a/Command/RunCommand.php b/Command/RunCommand.php index 98898c1f..b2d36cc3 100644 --- a/Command/RunCommand.php +++ b/Command/RunCommand.php @@ -18,7 +18,7 @@ namespace JMS\JobQueueBundle\Command; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use JMS\JobQueueBundle\Entity\Job; use JMS\JobQueueBundle\Entity\Repository\JobManager; use JMS\JobQueueBundle\Event\NewOutputEvent; @@ -443,8 +443,8 @@ private function getBasicCommandLineArgs(): array return $args; } - private function getEntityManager(): EntityManager + private function getEntityManager(): EntityManagerInterface { - return /** @var EntityManager */ $this->registry->getManagerForClass('JMSJobQueueBundle:Job'); + return /** @var EntityManagerInterface */ $this->registry->getManagerForClass('JMSJobQueueBundle:Job'); } } diff --git a/Command/ScheduleCommand.php b/Command/ScheduleCommand.php index 27a99c95..a9cb1a31 100644 --- a/Command/ScheduleCommand.php +++ b/Command/ScheduleCommand.php @@ -3,7 +3,7 @@ namespace JMS\JobQueueBundle\Command; use Doctrine\Common\Persistence\ManagerRegistry; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query; use JMS\JobQueueBundle\Console\CronCommand; use JMS\JobQueueBundle\Cron\CommandScheduler; @@ -113,7 +113,7 @@ private function scheduleJobs(OutputInterface $output, array $jobSchedulers, arr private function acquireLock($commandName, \DateTime $lastRunAt) { - /** @var EntityManager $em */ + /** @var EntityManagerInterface $em */ $em = $this->registry->getManagerForClass(CronJob::class); $con = $em->getConnection(); @@ -166,7 +166,7 @@ private function populateJobSchedulers() return $schedulers; } - private function populateJobsLastRunAt(EntityManager $em, array $jobSchedulers) + private function populateJobsLastRunAt(EntityManagerInterface $em, array $jobSchedulers) { $jobsLastRunAt = array(); diff --git a/Controller/JobController.php b/Controller/JobController.php index 0719ccf1..e7104db4 100644 --- a/Controller/JobController.php +++ b/Controller/JobController.php @@ -3,7 +3,7 @@ namespace JMS\JobQueueBundle\Controller; use Doctrine\Common\Util\ClassUtils; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use JMS\JobQueueBundle\Entity\Job; use JMS\JobQueueBundle\Entity\Repository\JobManager; use JMS\JobQueueBundle\View\JobFilter; @@ -149,7 +149,7 @@ public function retryJobAction(Job $job) return new RedirectResponse($url, 201); } - private function getEm(): EntityManager + private function getEm(): EntityManagerInterface { return $this->get('doctrine')->getManagerForClass(Job::class); } diff --git a/Entity/Repository/JobManager.php b/Entity/Repository/JobManager.php index 78e66ef7..b4169f7a 100644 --- a/Entity/Repository/JobManager.php +++ b/Entity/Repository/JobManager.php @@ -22,7 +22,7 @@ use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Type; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\ResultSetMappingBuilder; use JMS\JobQueueBundle\Entity\Job; @@ -425,7 +425,7 @@ public function getAvailableJobsForQueueCount($jobQueue) return count($result); } - private function getJobManager(): EntityManager + private function getJobManager(): EntityManagerInterface { return $this->registry->getManagerForClass(Job::class); }