<?php
namespace App\Entity;
use App\Entity\Traits\IdTrait;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\FileRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity(repositoryClass=FileRepository::class)
*/
class File
{
use IdTrait;
public const ACCEPTED_FILE_TYPE = [
"text/html",
"image/jpeg",
"image/png",
"application/pdf",
"application/vnd.oasis.opendocument.text",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
];
/**
* @ORM\OneToMany(targetEntity=Application::class, mappedBy="file")
* @ORM\JoinColumn(nullable=true)
*/
private ?Collection $application;
public function __construct(
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $fileName,
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $originalFileName,
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $extension,
/**
* @ORM\Column(type="datetime")
*/
private DateTimeInterface $createdAt,
/**
* @ORM\Column(type="datetime")
*/
private DateTimeInterface $updatedAt,
/**
* @ORM\OneToMany(targetEntity=Company::class, mappedBy="logo", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=true)
*/
private ?Collection $company,
/**
* @ORM\ManyToOne(targetEntity=Blog::class, inversedBy="Photo",cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=true)
*/
private ?Blog $blog,
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $invoiceId = null
){
$this->application = new ArrayCollection();
}
public function __clone()
{
$this->id = null;
$this->fileName = null;
$this->company = null;
$this->blog = null;
}
public function cloneObject(string $filename): self
{
$clone = clone $this;
$clone->fileName = $filename;
return $clone;
}
public function getId(): ?int
{
return $this->id;
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileName(string $fileName): self
{
$this->fileName = $fileName;
return $this;
}
public function getOriginalFileName(): ?string
{
return $this->originalFileName;
}
public function setOriginalFileName(string $originalFileName): self
{
$this->originalFileName = $originalFileName;
return $this;
}
public function getExtension(): ?string
{
return $this->extension;
}
public function setExtension(string $extension): self
{
$this->extension = $extension;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection|Company[]
*/
public function getCompany(): ?Collection
{
return $this->company;
}
public function addCompany(?Company $company): self
{
if (!$this->company->contains($company)) {
$this->company[] = $company;
$company->setLogo($this);
}
return $this;
}
public function removeCompany(?Company $company): self
{
if ($this->company->removeElement($company)) {
if ($company->getLogo() === $this) {
$company->setLogo(null);
}
}
return $this;
}
public function getBlog(): ?Blog
{
return $this->blog;
}
public function setBlog(?Blog $blog): self
{
$this->blog = $blog;
return $this;
}
/**
* @return Collection|Application[]
*/
public function getApplication(): Collection
{
return $this->application;
}
public function addApplication(Application $application): self
{
if (!$this->application->contains($application)) {
$this->application[] = $application;
$application->setFile($this);
}
return $this;
}
public function removeApplication(Application $application): self
{
if ($this->application->removeElement($application)) {
if ($application->getFile() === $this) {
$application->setFile(null);
}
}
return $this;
}
public function getInvoiceId(): ?string
{
return $this->invoiceId;
}
public function setInvoiceId(?string $invoiceId): self
{
$this->invoiceId = $invoiceId;
return $this;
}
}