Improvements in trace
testing/ogcore-api/pipeline/head There was a failure building this commit Details

pull/13/head
Manuel Aranda Rosales 2024-11-15 09:39:56 +01:00
parent 03e36f6218
commit 805fd70026
1 changed files with 27 additions and 2 deletions

View File

@ -2,7 +2,32 @@
namespace App\Service\Trace;
class CreateService
{
use App\Entity\Client;
use App\Entity\Command;
use App\Entity\Trace;
use Doctrine\ORM\EntityManagerInterface;
readonly class CreateService
{
public function __construct(
private EntityManagerInterface $entityManager
)
{
}
public function __invoke(Client $client, Command $command, string $status, ?string $jobId = null, array $input): Trace
{
$trace = new Trace();
$trace->setClient($client);
$trace->setCommand($command ?? null);
$trace->setStatus($status);
$trace->setJobId($jobId);
$trace->setExecutedAt(new \DateTime());
$trace->setInput($input);
$this->entityManager->persist($trace);
$this->entityManager->flush();
return $trace;
}
}