src/Entity/PageBlockCarouselItem.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PageBlockCarouselItemRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. /**
  9.  * @ORM\Entity(repositoryClass=PageBlockCarouselItemRepository::class)
  10.  * @Vich\Uploadable
  11.  */
  12. class PageBlockCarouselItem
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="text", nullable=true)
  22.      */
  23.     private $text;
  24.     /**
  25.      * @ORM\Column(type="string", length=255, nullable=true)
  26.      */
  27.     private $imageName;
  28.     /**
  29.      * @Assert\File(
  30.      *     maxSize = "10M",
  31.      *     mimeTypes = {"image/jpeg", "image/png", "image/bmp"},
  32.      * )
  33.      * @Vich\UploadableField(mapping="home_pageblock_carousel", fileNameProperty="imageName")
  34.      * @var File
  35.      */
  36.     private $imageFile;
  37.     /**
  38.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  39.      */
  40.     private $updatedAt;
  41.     public function __construct()
  42.     {
  43.         $this->updatedAt = new \DateTime();
  44.     }
  45.     /**
  46.      * @ORM\ManyToOne(targetEntity=PageBlockCarousel::class, inversedBy="items")
  47.      * @ORM\JoinColumn(nullable=false)
  48.      */
  49.     private $pageBlockCarousel;
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getPageBlockCarousel(): ?PageBlockCarousel
  55.     {
  56.         return $this->pageBlockCarousel;
  57.     }
  58.     public function setPageBlockCarousel(?PageBlockCarousel $pageBlockCarousel): self
  59.     {
  60.         $this->pageBlockCarousel $pageBlockCarousel;
  61.         return $this;
  62.     }
  63.     public function getText(): ?string
  64.     {
  65.         return $this->text;
  66.     }
  67.     public function setText(?string $text): self
  68.     {
  69.         $this->text $text;
  70.         return $this;
  71.     }
  72.     public function getImageName(): ?string
  73.     {
  74.         return $this->imageName;
  75.     }
  76.     public function setImageName(?string $imageName): PageBlockCarouselItem
  77.     {
  78.         $this->imageName $imageName;
  79.         return $this;
  80.     }
  81.     public function getImageFile(): ?File
  82.     {
  83.         return $this->imageFile;
  84.     }
  85.     /**
  86.      * @param File|null $image
  87.      */
  88.     public function setImageFile(File $image null)
  89.     {
  90.         $this->imageFile $image;
  91.         // It is required that at least one field changes if you are using Doctrine,
  92.         // otherwise the event listeners won't be called and the file is lost
  93.         if ($image) {
  94.             // if 'updatedAt' is not defined in your entity, use another property
  95.             $this->updatedAt = new \DateTime('now');
  96.         }
  97.     }
  98. }