src/Entity/Documents.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Traits\CommonTrt;
  4. use Doctrine\ORM\Mapping as ORM;
  5. // use JMS\Serializer\Annotation\Exclude;
  6. use App\Repository\DocumentsRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Component\HttpFoundation\File\UploadedFile;
  13. /**
  14.  * @ORM\Entity(repositoryClass=DocumentsRepository::class)
  15.  * @Vich\Uploadable()
  16.  */
  17. class Documents
  18. {
  19.     use CommonTrt;
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $name;
  30.     /**
  31.      * @Assert\File(
  32.      *     maxSize = "10240M",
  33.      *     mimeTypes = {"application/pdf", "application/x-pdf", "image/jpeg", "image/png"},
  34.      *     mimeTypesMessage = "Veillez charger un fichier valide"
  35.      * )
  36.      * @Vich\UploadableField(mapping="uploads", fileNameProperty="fileName", mimeType="fileType", size="imageSize")
  37.      * @var File|null
  38.      */
  39.     private $documentFile;
  40.     /**
  41.      * @ORM\Column(type="string", length=255, nullable=true)
  42.      */
  43.     private $fileName;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private $fileType;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private $description;
  52.     /**
  53.      * @ORM\Column(type="integer", nullable=true)
  54.      *
  55.      * @var int|null
  56.      */
  57.     private $imageSize;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $url;
  62.     /**
  63.      * @ORM\Column(type="string", length=255)
  64.      */
  65.     private $slug;
  66.     /**
  67.      * @ORM\ManyToMany(targetEntity=Tag::class, inversedBy="documents")
  68.      */
  69.     private $tag;
  70.     /**
  71.      * @ORM\Column(type="integer", nullable=true)
  72.      */
  73.     private $fileSize;
  74.     /**
  75.      * @ORM\Column(type="json", nullable=true)
  76.      */
  77.     private $allImages = [];
  78.     /**
  79.      * @ORM\Column(type="integer", nullable=true)
  80.      */
  81.     private $orderNumber;
  82.     /**
  83.      * @ORM\Column(type="integer", nullable=true)
  84.      */
  85.     private $docsType;
  86.     /**
  87.      * @ORM\ManyToMany(targetEntity=News::class, mappedBy="docs")
  88.      */
  89.     private $news;
  90.     /**
  91.      * @ORM\ManyToOne(targetEntity=Lang::class, inversedBy="documents")
  92.      */
  93.     private $langue;
  94.     /**
  95.      * @ORM\ManyToMany(targetEntity=Header::class, mappedBy="docs")
  96.      */
  97.     private $headers;
  98.     /**
  99.      * @ORM\Column(type="boolean", nullable=true)
  100.      */
  101.     private $isActive;
  102.     public function __construct()
  103.     {
  104.         $this->tag = new ArrayCollection();
  105.         $this->news = new ArrayCollection();
  106.         $this->headers = new ArrayCollection();
  107.     }
  108.     public function getId(): ?int
  109.     {
  110.         return $this->id;
  111.     }
  112.     public function getName(): ?string
  113.     {
  114.         return $this->name;
  115.     }
  116.     public function setName(string $name): self
  117.     {
  118.         $this->name = $name;
  119.         return $this;
  120.     }
  121.     /**
  122.      * Get the value of document_file
  123.      *
  124.      * @return  File|null
  125.      */
  126.     public function getDocumentFile(): ?File
  127.     {
  128.         return $this->documentFile;
  129.     }
  130.     /**
  131.      * Set the value of document_file
  132.      *
  133.      * @param File|null $document_file
  134.      *
  135.      * @return  self
  136.      */
  137.     public function setDocumentFile($documentFile)
  138.     {
  139.         $this->documentFile = $documentFile;
  140.         if ($documentFile instanceof UploadedFile) {
  141.             $this->updatedAt = new \DateTime();
  142.         }
  143.         return $this;
  144.     }
  145.     public function getFileName(): ?string
  146.     {
  147.         return $this->fileName;
  148.     }
  149.     public function setFileName(?string $fileName): self
  150.     {
  151.         $this->fileName = $fileName;
  152.         return $this;
  153.     }
  154.     public function getFileType(): ?string
  155.     {
  156.         return $this->fileType;
  157.     }
  158.     public function setFileType(?string $fileType): self
  159.     {
  160.         $this->fileType = $fileType;
  161.         return $this;
  162.     }
  163.     public function getDescription(): ?string
  164.     {
  165.         return $this->description;
  166.     }
  167.     public function setDescription(?string $description): self
  168.     {
  169.         $this->description = $description;
  170.         return $this;
  171.     }
  172.     public function getSlug(): ?string
  173.     {
  174.         return $this->slug;
  175.     }
  176.     public function setSlug(string $slug): self
  177.     {
  178.         $this->slug = $slug;
  179.         return $this;
  180.     }
  181.     public function setImageSize(?int $imageSize): void
  182.     {
  183.         $this->imageSize = $imageSize;
  184.     }
  185.     public function getImageSize(): ?int
  186.     {
  187.         return $this->imageSize;
  188.     }
  189.     public function getUrl(): ?string
  190.     {
  191.         return $this->url;
  192.     }
  193.     public function setUrl(?string $url): self
  194.     {
  195.         $this->url = $url;
  196.         return $this;
  197.     }
  198.     /**
  199.      * @return Collection|Tag[]
  200.      */
  201.     public function getTag(): Collection
  202.     {
  203.         return $this->tag;
  204.     }
  205.     public function addTag(Tag $tag): self
  206.     {
  207.         if (!$this->tag->contains($tag)) {
  208.             $this->tag[] = $tag;
  209.         }
  210.         return $this;
  211.     }
  212.     public function removeTag(Tag $tag): self
  213.     {
  214.         $this->tag->removeElement($tag);
  215.         return $this;
  216.     }
  217.     public function getFileSize(): ?int
  218.     {
  219.         return $this->fileSize;
  220.     }
  221.     public function setFileSize(?int $fileSize): self
  222.     {
  223.         $this->fileSize = $fileSize;
  224.         return $this;
  225.     }
  226.     public function getAllImages(): ?array
  227.     {
  228.         return $this->allImages;
  229.     }
  230.     public function setAllImages(?array $allImages): self
  231.     {
  232.         $this->allImages = $allImages;
  233.         return $this;
  234.     }
  235.     public function getOrderNumber(): ?int
  236.     {
  237.         return $this->orderNumber;
  238.     }
  239.     public function setOrderNumber(?int $orderNumber): self
  240.     {
  241.         $this->orderNumber = $orderNumber;
  242.         return $this;
  243.     }
  244.     public function getDocsType(): ?int
  245.     {
  246.         return $this->docsType;
  247.     }
  248.     public function setDocsType(int $docsType): self
  249.     {
  250.         $this->docsType = $docsType;
  251.         return $this;
  252.     }
  253.     /**
  254.      * @return Collection|Header[]
  255.      */
  256.     public function getHeaders(): Collection
  257.     {
  258.         return $this->headers;
  259.     }
  260.     /**
  261.      * @return Collection<int, News>
  262.      */
  263.     public function getNews(): Collection
  264.     {
  265.         return $this->news;
  266.     }
  267.     public function addNews(News $news): self
  268.     {
  269.         if (!$this->news->contains($news)) {
  270.             $this->news[] = $news;
  271.             $news->addDoc($this);
  272.         }
  273.         return $this;
  274.     }
  275.     public function removeNews(News $news): self
  276.     {
  277.         if ($this->news->removeElement($news)) {
  278.             $news->removeDoc($this);
  279.         }
  280.         return $this;
  281.     }
  282.     public function getLangue(): ?Lang
  283.     {
  284.         return $this->langue;
  285.     }
  286.     public function setLangue(?Lang $langue): self
  287.     {
  288.         $this->langue = $langue;
  289.         return $this;
  290.     }
  291.     public function addHeader(Header $header): self
  292.     {
  293.         if (!$this->headers->contains($header)) {
  294.             $this->headers[] = $header;
  295.             $header->addDoc($this);
  296.         }
  297.         return $this;
  298.     }
  299.     public function removeHeader(Header $header): self
  300.     {
  301.         if ($this->headers->removeElement($header)) {
  302.             $header->removeDoc($this);
  303.         }
  304.         return $this;
  305.     }
  306.     public function isIsActive(): ?bool
  307.     {
  308.         return $this->isActive;
  309.     }
  310.     public function setIsActive(?bool $isActive): self
  311.     {
  312.         $this->isActive = $isActive;
  313.         return $this;
  314.     }
  315. }