stash light
This commit is contained in:
54
src/Service/IngestJobService.php
Normal file
54
src/Service/IngestJobService.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\IngestJob;
|
||||
use App\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
final class IngestJobService
|
||||
{
|
||||
public function __construct(private EntityManagerInterface $em)
|
||||
{
|
||||
}
|
||||
|
||||
public function startJob(
|
||||
string $type,
|
||||
?User $user = null,
|
||||
?Uuid $documentId = null,
|
||||
?Uuid $documentVersionId = null,
|
||||
?string $logPath = null
|
||||
): IngestJob
|
||||
{
|
||||
$job = new IngestJob($type);
|
||||
$job->setStartedBy($user);
|
||||
$job->setDocumentId($documentId);
|
||||
$job->setDocumentVersionId($documentVersionId);
|
||||
$job->setLogPath($logPath);
|
||||
|
||||
$this->em->persist($job);
|
||||
$this->em->flush();
|
||||
|
||||
return $job;
|
||||
}
|
||||
|
||||
public function markCompleted(IngestJob $job): void
|
||||
{
|
||||
$job->markCompleted();
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
public function markFailed(IngestJob $job, string $message): void
|
||||
{
|
||||
$job->markFailed($message);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
public function markAborted(IngestJob $job): void
|
||||
{
|
||||
$job->markAborted();
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user