36 lines
697 B
PHP
36 lines
697 B
PHP
<?php
|
|
|
|
namespace App\Service;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
use App\Entity\WarrantyAPILog;
|
|
|
|
class WarrantyAPILogger
|
|
{
|
|
protected $em;
|
|
|
|
public function __construct(EntityManagerInterface $em)
|
|
{
|
|
$this->em = $em;
|
|
}
|
|
|
|
public function logWarrantyInfo($log_data, $error, $user_id, $action, $source)
|
|
{
|
|
$log_entry = new WarrantyAPILog();
|
|
|
|
$err_aray = [];
|
|
$err_array[] = $error;
|
|
|
|
$log_entry->setApiUser($user_id)
|
|
->setErrors($err_array)
|
|
->setAllData($log_data)
|
|
->setAction($action)
|
|
->setSource($source);
|
|
|
|
$this->em->persist($log_entry);
|
|
$this->em->flush();
|
|
|
|
}
|
|
}
|
|
|