src/Entity/Classification.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClassificationRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Gedmo\Translatable\Translatable;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\HttpFoundation\File\UploadedFile;
  11. use Symfony\Component\Serializer\Annotation\Ignore;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use App\Entity\Translation\ClassificationTranslation;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use Symfony\Component\Serializer\Annotation\Groups;
  17. /**
  18.  * @ORM\Entity(repositoryClass=ClassificationRepository::class)
  19.  * @Gedmo\TranslationEntity(class="App\Entity\Translation\ClassificationTranslation")
  20.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  21.  * @Vich\Uploadable
  22.  */
  23. class Classification implements Translatable
  24. {
  25.     use TimestampableEntity;
  26.     use SetTranslationsTrait;
  27.     public const FIELDS = [
  28.         'title'
  29.      ];
  30.     /**
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue
  33.      * @ORM\Column(type="integer")
  34.      * @Groups("classification:list", "classification:item")
  35.      */
  36.     private $id;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      * @Gedmo\Translatable
  40.      * @Groups("classification:list", "classification:item")
  41.      */
  42.     private $title;
  43.     /**
  44.      * @var string
  45.      * @Ignore()
  46.      */
  47.     private $titleEn;
  48.     /**
  49.      * @var string
  50.      * @Ignore()
  51.      */
  52.     private $titleCa;
  53.  /**
  54.      * @Assert\File(
  55.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  56.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  57.      * )
  58.      * @Vich\UploadableField(mapping="result_image", fileNameProperty="imageName", size="imageSize")
  59.      * @var File|null
  60.      * @Ignore()
  61.      */
  62.     private $imageFile;
  63.     /**
  64.      * @ORM\Column(type="string")
  65.      *
  66.      * @var string|null
  67.      * @Groups("result:list", "result:item")
  68.      */
  69.     private $imageName;
  70.     /**
  71.      * @ORM\Column(type="integer")
  72.      *
  73.      * @var int|null
  74.      */
  75.     private $imageSize;
  76.     /**
  77.      * @Assert\File(
  78.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  79.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  80.      * )
  81.      * @Vich\UploadableField(mapping="result_image", fileNameProperty="imageNameEn", size="imageSizeEn")
  82.      * @var File|null
  83.      * @Ignore()
  84.      */
  85.     private $imageFileEn;
  86.     /**
  87.      * @ORM\Column(type="string", nullable=true)
  88.      *
  89.      * @var string|null
  90.      * @Groups("result:list", "result:item")
  91.      */
  92.     private $imageNameEn null;
  93.     /**
  94.      * @ORM\Column(type="integer", nullable=true)
  95.      *
  96.      * @var int|null
  97.      */
  98.     private $imageSizeEn null;
  99.     /**
  100.      * @Assert\File(
  101.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  102.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  103.      * )
  104.      * @Vich\UploadableField(mapping="result_image", fileNameProperty="imageNameCa", size="imageSizeCa")
  105.      * @var File|null
  106.      * @Ignore()
  107.      */
  108.     private $imageFileCa;
  109.     /**
  110.      * @ORM\Column(type="string", nullable=true)
  111.      *
  112.      * @var string|null
  113.      * @Groups("result:list", "result:item")
  114.      */
  115.     private $imageNameCa null;
  116.     /**
  117.      * @ORM\Column(type="integer", nullable=true)
  118.      *
  119.      * @var int|null
  120.      */
  121.     private $imageSizeCa null;
  122.     /**
  123.     * @ORM\OneToMany(
  124.     *   targetEntity="App\Entity\Translation\ClassificationTranslation",
  125.     *   mappedBy="object",
  126.     *   cascade={"persist", "remove"}
  127.     * )
  128.      * @Ignore()
  129.     */
  130.     private $translations;
  131.     /**
  132.      * @Gedmo\Locale
  133.      * Used locale to override Translation listener`s locale
  134.      * this is not a mapped field of entity metadata, just a simple property
  135.      */
  136.     private $locale;
  137.     /**
  138.      * @ORM\Column(type="datetime", nullable=true)
  139.      * @var \DateTime|null
  140.      */
  141.     protected $deletedAt;
  142.     /**
  143.      * Set or clear the deleted at timestamp.
  144.      *
  145.      * @return self
  146.      */
  147.     public function setDeletedAt(\DateTime $deletedAt null)
  148.     {
  149.         $this->deletedAt $deletedAt;
  150.         return $this;
  151.     }
  152.     /**
  153.      * Get the deleted at timestamp value. Will return null if
  154.      * the entity has not been soft deleted.
  155.      *
  156.      * @return \DateTime|null
  157.      */
  158.     public function getDeletedAt()
  159.     {
  160.         return $this->deletedAt;
  161.     }
  162.     public function setTranslatableLocale($locale)
  163.     {
  164.         $this->locale $locale;
  165.     }
  166.     /**
  167.      * @Assert\File(
  168.      *     mimeTypes = {"application/pdf", "application/x-pdf"},
  169.      *     mimeTypesMessage = "Please upload a valid PDF"
  170.      * )
  171.      * @Vich\UploadableField(mapping="classification", fileNameProperty="pdfName", size="pdfSize")
  172.      * @var File|null
  173.      * @Ignore()
  174.      */
  175.     private $pdfFile;
  176.     /**
  177.     * Classification constructor.
  178.     */
  179.     public function __construct()
  180.     {
  181.         $this->translations = new ArrayCollection();
  182.     }
  183.     public function getId(): ?int
  184.     {
  185.         return $this->id;
  186.     }
  187.     public function getTitle(): ?string
  188.     {
  189.         return $this->title;
  190.     }
  191.     public function setTitle(string $title): self
  192.     {
  193.         $this->title $title;
  194.         return $this;
  195.     }
  196.     /**
  197.      * @return mixed
  198.      */
  199.     public function getTitleEn()
  200.     {
  201.         return $this->titleEn;
  202.     }
  203.     /**
  204.      * @param string|null $titleEn
  205.      *
  206.      * @return $this
  207.      */
  208.     public function setTitleEn(?string $titleEn): self
  209.     {
  210.         $this->titleEn $titleEn;
  211.         return $this;
  212.     }
  213.     /**
  214.      * @return mixed
  215.      */
  216.     public function getTitleCa()
  217.     {
  218.         return $this->titleCa;
  219.     }
  220.     /**
  221.      * @param string|null $titleCa
  222.      *
  223.      * @return $this
  224.      */
  225.     public function setTitleCa(?string $titleCa): self
  226.     {
  227.         $this->titleCa $titleCa;
  228.         return $this;
  229.     }
  230.     /**
  231.      * @param File|UploadedFile|null $pdfFile
  232.      */
  233.     public function setPdfFile(?File $pdfFile null): void
  234.     {
  235.         $this->pdfFile $pdfFile;
  236.         if (null !== $pdfFile) {
  237.             $this->updatedAt = new \DateTimeImmutable();
  238.         }
  239.     }
  240.     public function getPdfFile(): ?File
  241.     {
  242.         return $this->pdfFile;
  243.     }
  244.     /**
  245.      * @ORM\Column(type="string", nullable=true)
  246.      *
  247.      * @var string|null
  248.      * @Groups("classification:list", "classification:item")
  249.      */
  250.     private $pdfName;
  251.     /**
  252.      * @ORM\Column(type="integer", nullable=true)
  253.      *
  254.      * @var int|null
  255.      */
  256.     private $pdfSize;
  257.     public function setPdfName(?string $pdfName): void
  258.     {
  259.         $this->pdfName $pdfName;
  260.     }
  261.     public function getPdfName(): ?string
  262.     {
  263.         return $this->pdfName;
  264.     }
  265.     public function setPdfSize(?int $pdfSize): void
  266.     {
  267.         $this->pdfSize $pdfSize;
  268.     }
  269.     public function getPdfSize(): ?int
  270.     {
  271.         return $this->pdfSize;
  272.     }
  273.     public function getTranslations()
  274.     {
  275.         return $this->translations;
  276.     }
  277.     public function addTranslation(ClassificationTranslation $t)
  278.     {
  279.         if (!$this->translations->contains($t)) {
  280.             $this->translations[] = $t;
  281.             $t->setObject($this);
  282.         }
  283.     }
  284.      /**
  285.      * @param File|UploadedFile|null $imageFile
  286.      */
  287.     public function setImageFile(?File $imageFile null): void
  288.     {
  289.         $this->imageFile $imageFile;
  290.         if (null !== $imageFile) {
  291.             $this->updatedAt = new \DateTimeImmutable();
  292.         }
  293.     }
  294.     public function getImageFile(): ?File
  295.     {
  296.         return $this->imageFile;
  297.     }
  298.     public function setImageName(?string $imageName): void
  299.     {
  300.         $this->imageName $imageName;
  301.     }
  302.     public function getImageName(): ?string
  303.     {
  304.         return $this->imageName;
  305.     }
  306.     public function setImageSize(?int $imageSize): void
  307.     {
  308.         $this->imageSize $imageSize;
  309.     }
  310.     public function getImageSize(): ?int
  311.     {
  312.         return $this->imageSize;
  313.     }
  314.     /**
  315.      * @param File|UploadedFile|null $imageFileEn
  316.      */
  317.     public function setImageFileEn(?File $imageFileEn null): void
  318.     {
  319.         $this->imageFileEn $imageFileEn;
  320.         if (null !== $imageFileEn) {
  321.             $this->updatedAt = new \DateTimeImmutable();
  322.         }
  323.     }
  324.     public function getImageFileEn(): ?File
  325.     {
  326.         return $this->imageFileEn;
  327.     }
  328.     public function setImageNameEn(?string $imageNameEn): void
  329.     {
  330.         $this->imageNameEn $imageNameEn;
  331.     }
  332.     public function getImageNameEn(): ?string
  333.     {
  334.         return $this->imageNameEn;
  335.     }
  336.     public function setImageSizeEn(?int $imageSizeEn): void
  337.     {
  338.         $this->imageSizeEn $imageSizeEn;
  339.     }
  340.     public function getImageSizeEn(): ?int
  341.     {
  342.         return $this->imageSizeEn;
  343.     }
  344.     /**
  345.      * @param File|UploadedFile|null $imageFileCa
  346.      */
  347.     public function setImageFileCa(?File $imageFileCa null): void
  348.     {
  349.         $this->imageFileCa $imageFileCa;
  350.         if (null !== $imageFileCa) {
  351.             $this->updatedAt = new \DateTimeImmutable();
  352.         }
  353.     }
  354.     public function getImageFileCa(): ?File
  355.     {
  356.         return $this->imageFileCa;
  357.     }
  358.     public function setImageNameCa(?string $imageNameCa): void
  359.     {
  360.         $this->imageNameCa $imageNameCa;
  361.     }
  362.     public function getImageNameCa(): ?string
  363.     {
  364.         return $this->imageNameCa;
  365.     }
  366.     public function setImageSizeCa(?int $imageSizeCa): void
  367.     {
  368.         $this->imageSizeCa $imageSizeCa;
  369.     }
  370.     public function getImageSizeCa(): ?int
  371.     {
  372.         return $this->imageSizeCa;
  373.     }
  374. }