src/Entity/File.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\IdTrait;
  4. use DateTimeInterface;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Repository\FileRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. /**
  10.  * @ORM\Entity(repositoryClass=FileRepository::class)
  11.  */
  12. class File
  13. {
  14.     use IdTrait;
  15.     public const ACCEPTED_FILE_TYPE = [
  16.         "text/html",
  17.         "image/jpeg",
  18.         "image/png",
  19.         "application/pdf",
  20.         "application/vnd.oasis.opendocument.text",
  21.         "application/msword",
  22.         "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  23.         "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  24.         "application/vnd.openxmlformats-officedocument.presentationml.presentation"
  25.     ];
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Application::class, mappedBy="file")
  28.      * @ORM\JoinColumn(nullable=true)
  29.      */
  30.     private ?Collection $application;
  31.     public function __construct(
  32.         /**
  33.          * @ORM\Column(type="string", length=255)
  34.          */
  35.         private ?string $fileName,
  36.         /**
  37.          * @ORM\Column(type="string", length=255)
  38.          */
  39.         private ?string $originalFileName,
  40.         /**
  41.          * @ORM\Column(type="string", length=255)
  42.          */
  43.         private ?string $extension,
  44.         /**
  45.          * @ORM\Column(type="datetime")
  46.          */
  47.         private DateTimeInterface $createdAt,
  48.         /**
  49.          * @ORM\Column(type="datetime")
  50.          */
  51.         private DateTimeInterface $updatedAt,
  52.         /**
  53.          * @ORM\OneToMany(targetEntity=Company::class, mappedBy="logo", cascade={"persist", "remove"})
  54.          * @ORM\JoinColumn(nullable=true)
  55.          */
  56.         private ?Collection $company,
  57.         /**
  58.          * @ORM\ManyToOne(targetEntity=Blog::class, inversedBy="Photo",cascade={"persist", "remove"})
  59.          * @ORM\JoinColumn(nullable=true)
  60.          */
  61.         private ?Blog $blog,
  62.         /**
  63.          * @ORM\Column(type="string", length=255, nullable=true)
  64.          */
  65.         private ?string $invoiceId = null
  66.     ){
  67.         $this->application = new ArrayCollection();
  68.     }
  69.     public function __clone()
  70.     {
  71.         $this->id = null;
  72.         $this->fileName = null;
  73.         $this->company = null;
  74.         $this->blog = null;
  75.     }
  76.     public function cloneObject(string $filename): self
  77.     {
  78.         $clone = clone $this;
  79.         $clone->fileName = $filename;
  80.         return $clone;
  81.     }
  82.     public function getId(): ?int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function getFileName(): ?string
  87.     {
  88.         return $this->fileName;
  89.     }
  90.     public function setFileName(string $fileName): self
  91.     {
  92.         $this->fileName = $fileName;
  93.         return $this;
  94.     }
  95.     public function getOriginalFileName(): ?string
  96.     {
  97.         return $this->originalFileName;
  98.     }
  99.     public function setOriginalFileName(string $originalFileName): self
  100.     {
  101.         $this->originalFileName = $originalFileName;
  102.         return $this;
  103.     }
  104.     public function getExtension(): ?string
  105.     {
  106.         return $this->extension;
  107.     }
  108.     public function setExtension(string $extension): self
  109.     {
  110.         $this->extension = $extension;
  111.         return $this;
  112.     }
  113.     public function getCreatedAt(): ?\DateTimeInterface
  114.     {
  115.         return $this->createdAt;
  116.     }
  117.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  118.     {
  119.         $this->createdAt = $createdAt;
  120.         return $this;
  121.     }
  122.     public function getUpdatedAt(): ?\DateTimeInterface
  123.     {
  124.         return $this->updatedAt;
  125.     }
  126.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  127.     {
  128.         $this->updatedAt = $updatedAt;
  129.         return $this;
  130.     }
  131.     /**
  132.      * @return  Collection|Company[]
  133.      */
  134.     public function getCompany(): ?Collection
  135.     {
  136.         return $this->company;
  137.     }
  138.     public function addCompany(?Company $company): self
  139.     {
  140.         if (!$this->company->contains($company)) {
  141.             $this->company[] = $company;
  142.             $company->setLogo($this);
  143.         }
  144.         return $this;
  145.     }
  146.     public function removeCompany(?Company $company): self
  147.     {
  148.         if ($this->company->removeElement($company)) {
  149.             if ($company->getLogo() === $this) {
  150.                 $company->setLogo(null);
  151.             }
  152.         }
  153.         return $this;
  154.     }
  155.     public function getBlog(): ?Blog
  156.     {
  157.         return $this->blog;
  158.     }
  159.     public function setBlog(?Blog $blog): self
  160.     {
  161.         $this->blog = $blog;
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return Collection|Application[]
  166.      */
  167.     public function getApplication(): Collection
  168.     {
  169.         return $this->application;
  170.     }
  171.     public function addApplication(Application $application): self
  172.     {
  173.         if (!$this->application->contains($application)) {
  174.             $this->application[] = $application;
  175.             $application->setFile($this);
  176.         }
  177.         return $this;
  178.     }
  179.     public function removeApplication(Application $application): self
  180.     {
  181.         if ($this->application->removeElement($application)) {
  182.             if ($application->getFile() === $this) {
  183.                 $application->setFile(null);
  184.             }
  185.         }
  186.         return $this;
  187.     }
  188.     public function getInvoiceId(): ?string
  189.     {
  190.         return $this->invoiceId;
  191.     }
  192.     public function setInvoiceId(?string $invoiceId): self
  193.     {
  194.         $this->invoiceId = $invoiceId;
  195.         return $this;
  196.     }
  197. }