src/Entity/BC/ImportLog.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\BC;
  3. use App\Repository\BC\ImportLogRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Ramsey\Uuid\Uuid;
  7. use Ramsey\Uuid\UuidInterface;
  8. #[ORM\Entity(repositoryClassImportLogRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. #[ORM\Index(name'idx_item_no_created'columns: ['item_no''created_at'])]
  11. class ImportLog
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\Column(typeTypes::STRINGlength255)]
  15.     private string $id;
  16.     #[ORM\Column(typeTypes::STRINGlength64)]
  17.     private string $itemNo;
  18.     #[ORM\Column(typeTypes::TEXT)]
  19.     private string $itemData;
  20.     #[ORM\Column(typeTypes::STRINGlength64nullabletrue)]
  21.     private ?string $productAffected null;
  22.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  23.     private ?array $variantsAffected null;
  24.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  25.     private ?array $errors null;
  26.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  27.     private ?array $warnings null;
  28.     #[ORM\Column(type'datetime_immutable')]
  29.     private \DateTimeImmutable $createdAt;
  30.     public function __construct(string $itemNostring $itemData, array $errors = [])
  31.     {
  32.         $uuid Uuid::uuid1();
  33.         $this->id sprintf('%s_%s'$itemNo$uuid->toString());
  34.         $this->itemNo $itemNo;
  35.         $this->itemData $itemData;
  36.         $this->errors $errors;
  37.         $this->createdAt = new \DateTimeImmutable();
  38.     }
  39.     public function getId(): string
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getUuid(): UuidInterface
  44.     {
  45.         $uuidPart explode('_'$this->id)[1];
  46.         return Uuid::fromString($uuidPart);
  47.     }
  48.     public function getItemNo(): string
  49.     {
  50.         return $this->itemNo;
  51.     }
  52.     public function getItemData(): string
  53.     {
  54.         return $this->itemData;
  55.     }
  56.     public function getCreatedAt(): \DateTimeImmutable
  57.     {
  58.         return $this->createdAt;
  59.     }
  60.     public function setProductAffected(?string $productAffected): void
  61.     {
  62.         $this->productAffected $productAffected;
  63.     }
  64.     public function getProductAffected(): ?string
  65.     {
  66.         return $this->productAffected;
  67.     }
  68.     public function setVariantsAffected(?array $variantsAffected): void
  69.     {
  70.         $this->variantsAffected $variantsAffected;
  71.     }
  72.     public function addVariantAffected(string $variantNo): void
  73.     {
  74.         $this->variantsAffected ??= [];
  75.         $this->variantsAffected[] = $variantNo;
  76.     }
  77.     public function getVariantsAffected(): ?array
  78.     {
  79.         return $this->variantsAffected;
  80.     }
  81.     public function setErrors(?array $errors): void
  82.     {
  83.         $this->errors $errors;
  84.     }
  85.     public function addError(string $error): void
  86.     {
  87.         $this->errors ??= [];
  88.         $this->errors[] = $error;
  89.     }
  90.     public function getErrors(): ?array
  91.     {
  92.         return $this->errors;
  93.     }
  94.     public function setWarnings(?array $warnings): void
  95.     {
  96.         $this->warnings $warnings;
  97.     }
  98.     public function addWarning(string $warning): void
  99.     {
  100.         $this->warnings ??= [];
  101.         if (in_array($warning$this->warningstrue)) {
  102.             return;
  103.         }
  104.         $this->warnings[] = $warning;
  105.     }
  106.     public function getWarnings(): ?array
  107.     {
  108.         return $this->warnings;
  109.     }
  110. }