src/Entity/BlogPostGalleryItem.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BlogPostGalleryItemRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\Form\FormInterface;
  7. use Symfony\Component\Form\FormTypeInterface;
  8. use Symfony\Component\Form\FormView;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. /**
  14.  * @ORM\Entity(repositoryClass=BlogPostGalleryItemRepository::class)
  15.  * @ORM\Entity
  16.  * @Vich\Uploadable
  17.  */
  18. class BlogPostGalleryItem
  19. {
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=BlogPostGallery::class, inversedBy="items")
  28.      * @ORM\JoinColumn(nullable=false)
  29.      */
  30.     private $gallery;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $mediaName;
  35.     /**
  36.      * @Assert\File(
  37.      *     maxSize = "2048k",
  38.      *     mimeTypes = {"image/jpeg", "image/png", "image/bmp", "video/mp4", "application/pdf"},
  39.      * )
  40.      * @Vich\UploadableField(mapping="home_pageblock_carousel", fileNameProperty="mediaName")
  41.      * @var File
  42.      */
  43.     private $mediaFile;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private $title;
  48.     /**
  49.      * @ORM\Column(type="text", nullable=true)
  50.      */
  51.     private $description;
  52.     /**
  53.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  54.      */
  55.     private $updatedAt;
  56.     public function __construct()
  57.     {
  58.         $this->updatedAt = new \Datetime();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getGallery(): ?BlogPostGallery
  65.     {
  66.         return $this->gallery;
  67.     }
  68.     public function setGallery(?BlogPostGallery $gallery): self
  69.     {
  70.         $this->gallery $gallery;
  71.         return $this;
  72.     }
  73.     public function getMediaName(): ?string
  74.     {
  75.         return $this->mediaName;
  76.     }
  77.     public function setMediaName(?string $mediaName): self
  78.     {
  79.         $this->mediaName $mediaName;
  80.         return $this;
  81.     }
  82.     public function getMediaFile(): ?File
  83.     {
  84.         return $this->mediaFile;
  85.     }
  86.     /**
  87.      * @param File|null $image
  88.      */
  89.     public function setMediaFile(File $mediaFile null)
  90.     {
  91.         $this->mediaFile $mediaFile;
  92.         // It is required that at least one field changes if you are using Doctrine,
  93.         // otherwise the event listeners won't be called and the file is lost
  94.         if ($mediaFile) {
  95.             $this->updatedAt = new \DateTime('now');
  96.         }
  97.     }
  98.     public function getTitle(): ?string
  99.     {
  100.         return $this->title;
  101.     }
  102.     public function setTitle(?string $title): self
  103.     {
  104.         $this->title $title;
  105.         return $this;
  106.     }
  107.     public function getDescription(): ?string
  108.     {
  109.         return $this->description;
  110.     }
  111.     public function setDescription(?string $description): self
  112.     {
  113.         $this->description $description;
  114.         return $this;
  115.     }
  116.     public function getUpdatedAt(): ?\DateTimeInterface
  117.     {
  118.         return $this->updatedAt;
  119.     }
  120.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  121.     {
  122.         $this->updatedAt $updatedAt;
  123.         return $this;
  124.     }
  125. }