src/Entity/Program.php line 28

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