src/Entity/ImportFile.php line 20
<?phpnamespace App\Entity;use DateTimeImmutable;use DateTimeInterface;use App\Enum\ImportFileType;use App\Enum\ImportFileStatus;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\HttpFoundation\File\File;use Vich\UploaderBundle\Mapping\Annotation as Vich;use Gedmo\Timestampable\Traits\TimestampableEntity;use Symfony\Component\HttpFoundation\File\UploadedFile;#[ORM\Entity(repositoryClass: 'App\Repository\ImportFileRepository')]#[Vich\Uploadable]class ImportFile{use TimestampableEntity;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column(type: 'integer')]private $id;#[ORM\Column(type: 'string', length: 255, nullable: true)]private $file;#[ORM\Column(type: 'integer')]private $total = 0;#[ORM\Column(type: 'integer')]private $done = 0;#[ORM\Column(length: 255)]private ImportFileType $type;#[ORM\Column(length: 255)]private ImportFileStatus $status = ImportFileStatus::STATUS_NEW;#[ORM\Column(type: 'integer')]private $processed = 0;#[ORM\Column(type: 'integer')]private $success = 0;#[ORM\Column(type: 'integer')]private $failed = 0;#[ORM\Column(type: 'datetime', nullable: true)]private $started_at;#[ORM\Column(type: 'datetime', nullable: true)]private $completed_at;#[ORM\Column(type: 'json', nullable: true)]private $errors = [];#[ORM\Column(type: 'json', nullable: true)]private $data = [];public $dataFormatted;public function getId(): ?int{return $this->id;}public function getFile(): ?string{return $this->file;}public function setFile(?string $file): self{$this->file = $file;return $this;}#[Vich\UploadableField(mapping: "import_file", fileNameProperty: "file")]private $uploadedFile;#[ORM\ManyToOne(inversedBy: 'importFiles')]private ?User $user = null;#[ORM\OneToMany(mappedBy: 'importFile', targetEntity: Order::class)]private Collection $orders;public function __construct(){$this->orders = new ArrayCollection();}public function getTotal(): ?int{return $this->total;}public function setTotal(int $total): self{$this->total = $total;return $this;}public function getDone(): ?int{return $this->done;}public function setDone(int $done): self{$this->done = $done;return $this;}public function getStatus(): ?ImportFileStatus{return $this->status;}public function setStatus(ImportFileStatus $status): self{$this->status = $status;return $this;}public function getData(): ?array{return $this->data;}public function setData(?array $data): self{$this->data = $data;return $this;}/*** If manually uploading a file (i.e. not using Symfony Form) ensure an instance* of 'UploadedFile' is injected into this setter to trigger the update. If this* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter* must be able to accept an instance of 'File' as the bundle will inject one here* during Doctrine hydration.** @param File|UploadedFile|null $uploadedFile*/public function setUploadedFile(?File $uploadedFile = null): void{$this->uploadedFile = $uploadedFile;if (null !== $uploadedFile) {// It is required that at least one field changes if you are using doctrine// otherwise the event listeners won't be called and the file is lost$this->updatedAt = new DateTimeImmutable();}}/*** @return File|null*/public function getUploadedFile(): ?File{return $this->uploadedFile;}/*** @return mixed*/public function getType(): ImportFileType{return $this->type;}/*** @param mixed $type*/public function setType(ImportFileType $type): void{$this->type = $type;}public function getProcessed(): ?int{return $this->processed;}public function setProcessed(int $processed): self{$this->processed = $processed;return $this;}public function getSuccess(): ?int{return $this->success;}public function setSuccess(int $success): self{$this->success = $success;return $this;}public function getFailed(): ?int{return $this->failed;}public function setFailed(int $failed): self{$this->failed = $failed;return $this;}public function getStartedAt(): ?DateTimeInterface{return $this->started_at;}public function setStartedAt(?DateTimeInterface $started_at): self{$this->started_at = $started_at;return $this;}public function getCompletedAt(): ?DateTimeInterface{return $this->completed_at;}public function setCompletedAt(?DateTimeInterface $completed_at): self{$this->completed_at = $completed_at;return $this;}public function getErrors(): ?array{return $this->errors;}public function setErrors(?array $errors): self{$this->errors = $errors;return $this;}public function getUser(): ?User{return $this->user;}public function setUser(?User $user): static{$this->user = $user;return $this;}public function __toString(): string{return $this->file;}/*** @return Collection<int, Order>*/public function getOrders(): Collection{return $this->orders;}public function addOrder(Order $order): static{if (!$this->orders->contains($order)) {$this->orders->add($order);$order->setImportFile($this);}return $this;}public function removeOrder(Order $order): static{if ($this->orders->removeElement($order)) {// set the owning side to null (unless already changed)if ($order->getImportFile() === $this) {$order->setImportFile(null);}}return $this;}}