. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\Core\Job\Processing; use Espo\Core\Job\Job\Status; use Espo\Entities\Job; use Espo\ORM\EntityManager; use Espo\ORM\Name\Attribute; use Exception; class JobProvider { public function __construct( private EntityManager $entityManager, ) {} /** * @throws Exception */ public function get(string $id): Job { $job = $this->entityManager ->getRDBRepositoryByClass(Job::class) ->forUpdate() ->where([Attribute::ID => $id]) ->findOne(); if (!$job) { throw new Exception("Job $id not found."); } if ($job->getStatus() !== Status::READY) { throw new Exception("Job $id is not in status Ready."); } return $job; } }