src/Entity/Gallery.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\GalleryRepository;
  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\Groups;
  12. use Symfony\Component\Serializer\Annotation\Ignore;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use App\Entity\Translation\GalleryTranslation;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. /**
  18.  * @ORM\Entity(repositoryClass=GalleryRepository::class)
  19.  * @Gedmo\TranslationEntity(class="App\Entity\Translation\GalleryTranslation")
  20.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  21.  * @Vich\Uploadable
  22.  */
  23. class Gallery implements Translatable
  24. {
  25.     use TimestampableEntity;
  26.     use SetTranslationsTrait;
  27.     public const FIELDS = [
  28.         'title',
  29.         'description'
  30.      ];
  31.     /**
  32.      * @ORM\Id
  33.      * @ORM\GeneratedValue
  34.      * @ORM\Column(type="integer")
  35.      * @Groups("gallery:list", "banner:list", "banner:item")
  36.      */
  37.     private $id;
  38.     /**
  39.      * @ORM\Column(type="string", length=255)
  40.      * @Gedmo\Translatable
  41.      * @Groups("gallery:list", "banner:list", "banner:item")
  42.      */
  43.     private $title;
  44.     /**
  45.      * @var string
  46.      * @Ignore()
  47.      */
  48.     private $titleEn;
  49.     /**
  50.      * @var string
  51.      * @Ignore()
  52.      */
  53.     private $titleCa;
  54.     /**
  55.      * @ORM\Column(type="text")
  56.      * @Groups("gallery:list", "banner:list", "banner:item")
  57.      */
  58.     private $description;
  59.     /**
  60.      * @var string
  61.      * @Ignore()
  62.      */
  63.     private $descriptionEn;
  64.     /**
  65.      * @var string
  66.      * @Ignore()
  67.      */
  68.     private $descriptionCa;
  69.     /**
  70.      * @ORM\Column(type="date")
  71.      * @Groups("gallery:list", "banner:list", "banner:item")
  72.      */
  73.     private $date;
  74.     /**
  75.      * @ORM\Column(type="string")
  76.      *
  77.      * @var string|null
  78.      * @Groups("gallery:list", "banner:list", "banner:item")
  79.      */
  80.     private $imageName;
  81.     /**
  82.      * @ORM\Column(type="integer")
  83.      *
  84.      * @var int|null
  85.      * @Ignore()
  86.      */
  87.     private $imageSize;
  88.     /**
  89.     * @ORM\OneToMany(
  90.     *   targetEntity="App\Entity\Translation\GalleryTranslation",
  91.     *   mappedBy="object",
  92.     *   cascade={"persist", "remove"}
  93.     * )
  94.      * @Ignore()
  95.     */
  96.     private $translations;
  97.     /**
  98.      * @ORM\Column(type="datetime", nullable=true)
  99.      * @var \DateTime|null
  100.      */
  101.     protected $deletedAt;
  102.     /**
  103.      * Set or clear the deleted at timestamp.
  104.      *
  105.      * @return self
  106.      */
  107.     public function setDeletedAt(\DateTime $deletedAt null)
  108.     {
  109.         $this->deletedAt $deletedAt;
  110.         return $this;
  111.     }
  112.     /**
  113.      * Get the deleted at timestamp value. Will return null if
  114.      * the entity has not been soft deleted.
  115.      *
  116.      * @return \DateTime|null
  117.      */
  118.     public function getDeletedAt()
  119.     {
  120.         return $this->deletedAt;
  121.     }
  122.     /**
  123.     * Gallery constructor.
  124.     */
  125.     public function __construct()
  126.     {
  127.         $this->translations = new ArrayCollection();
  128.     }
  129.     public function getId(): ?int
  130.     {
  131.         return $this->id;
  132.     }
  133.     public function getTitle(): ?string
  134.     {
  135.         return $this->title;
  136.     }
  137.     public function setTitle(string $title): self
  138.     {
  139.         $this->title $title;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return string |null
  144.      */
  145.     public function getTitleEn(): ?string
  146.     {
  147.         return $this->titleEn;
  148.     }
  149.     /**
  150.      * @param string|null $titleEn
  151.      *
  152.      * @return $this
  153.      */
  154.     public function setTitleEn(?string $titleEn): self
  155.     {
  156.         $this->titleEn $titleEn;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return string |null
  161.      */
  162.     public function getTitleCa(): ?string
  163.     {
  164.         return $this->titleCa;
  165.     }
  166.     /**
  167.      * @param string|null $titleCa
  168.      *
  169.      * @return $this
  170.      */
  171.     public function setTitleCa(?string $titleCa): self
  172.     {
  173.         $this->titleCa $titleCa;
  174.         return $this;
  175.     }
  176.     public function getDescription(): ?string
  177.     {
  178.         return $this->description;
  179.     }
  180.     public function setDescription(string $description): self
  181.     {
  182.         $this->description $description;
  183.         return $this;
  184.     }
  185.     public function getDate(): ?\DateTimeInterface
  186.     {
  187.         return $this->date;
  188.     }
  189.     public function setDate(\DateTimeInterface $date): self
  190.     {
  191.         $this->date $date;
  192.         return $this;
  193.     }
  194.     /**
  195.      * @Gedmo\Locale
  196.      */
  197.     private $locale;
  198.     public function setTranslatableLocale($locale)
  199.     {
  200.         $this->locale $locale;
  201.     }
  202.     /**
  203.      * @Assert\File(
  204.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  205.      *     mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
  206.      * )
  207.      * @Vich\UploadableField(mapping="gallery", fileNameProperty="imageName", size="imageSize")
  208.      * @var File|null
  209.      * @Ignore()
  210.      */
  211.     private $imageFile;
  212.     /**
  213.      * @param File|UploadedFile|null $imageFile
  214.      */
  215.     public function setImageFile(?File $imageFile null): void
  216.     {
  217.         $this->imageFile $imageFile;
  218.         if (null !== $imageFile) {
  219.             $this->updatedAt = new \DateTimeImmutable();
  220.         }
  221.     }
  222.     public function getImageFile(): ?File
  223.     {
  224.         return $this->imageFile;
  225.     }
  226.     public function setImageName(?string $imageName): void
  227.     {
  228.         $this->imageName $imageName;
  229.     }
  230.     public function getImageName(): ?string
  231.     {
  232.         return $this->imageName;
  233.     }
  234.     public function setImageSize(?int $imageSize): void
  235.     {
  236.         $this->imageSize $imageSize;
  237.     }
  238.     public function getImageSize(): ?int
  239.     {
  240.         return $this->imageSize;
  241.     }
  242.     public function getTranslations()
  243.     {
  244.         return $this->translations;
  245.     }
  246.     public function addTranslation(GalleryTranslation $t)
  247.     {
  248.         if (!$this->translations->contains($t)) {
  249.             $this->translations[] = $t;
  250.             $t->setObject($this);
  251.         }
  252.     }
  253.     /**
  254.      * @return string|null
  255.      */
  256.     public function getDescriptionCa(): ?string
  257.     {
  258.         return $this->descriptionCa;
  259.     }
  260.     /**
  261.      * @param string|null $descriptionCa
  262.      */
  263.     public function setDescriptionCa(?string $descriptionCa): void
  264.     {
  265.         $this->descriptionCa $descriptionCa;
  266.     }
  267.     /**
  268.      * @return string |null
  269.      */
  270.     public function getDescriptionEn(): ?string
  271.     {
  272.         return $this->descriptionEn;
  273.     }
  274.     /**
  275.      * @param string|null $descriptionEn
  276.      */
  277.     public function setDescriptionEn(?string $descriptionEn): void
  278.     {
  279.         $this->descriptionEn $descriptionEn;
  280.     }
  281. }