resq/src/Entity/WarrantyAPILog.php
2021-05-19 08:10:18 +00:00

164 lines
2.9 KiB
PHP

<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
use DateTime;
/**
* @ORM\Entity
* @ORM\Table(name="warranty_api_log")
*/
class WarrantyAPILog
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// date created
/**
* @ORM\Column(type="datetime")
*/
protected $date_create;
// user that created warranty
/**
* @ORM\Column(type="string", length=32)
*/
protected $api_user;
// data sent
/**
* @ORM\Column(type="json")
*/
protected $all_data;
// errors
/**
* @ORM\Column(type="array", nullable=true)
*/
protected $errors;
// action
/**
* @ORM\Column(type="string", length=20)
*/
protected $action;
// source
/**
* @ORM\Column(type="string", length=30)
*/
protected $source;
public function __construct()
{
$this->date_create = new DateTime();
$this->errors = new ArrayCollection();
$this->all_data = [];
$this->action = '';
$this->source = '';
}
public function getID()
{
return $this->id;
}
public function setDateCreate(DateTime $date_create)
{
$this->date_create = $date_create;
return $this;
}
public function getDateCreate()
{
return $this->date_create;
}
public function setApiUser($api_user)
{
$this->api_user = $api_user;
return $this;
}
public function getApiUser()
{
return $this->api_user;
}
public function addAllData($id, $value)
{
$this->all_data[$id] = $value;
return $this;
}
public function setAllData($all_data)
{
$this->all_data = $all_data;
return $this;
}
public function getAllData($id)
{
// return null if we don't have it
if (!isset($this->all_data[$id]))
return null;
return $this->all_data[$id];
}
public function getErrors()
{
return $this->errors;
}
public function setErrors(array $errors)
{
$this->errors = new ArrayCollection();
foreach ($errors as $error)
{
$this->errors->add($error);
}
return $this;
}
public function clearErrors()
{
$this->errors = new ArrayCollection();
return $this;
}
public function setAction($action)
{
$this->action = $action;
return $this;
}
public function getAction()
{
return $this->action;
}
public function setSource($source)
{
$this->source = $source;
return $this;
}
public function getSource()
{
return $this->source;
}
}