src/Entity/Gos/ProductMovie.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\HttpFoundation\File\File;
  5. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\ProductMovieRepository")
  9.  * @Vich\Uploadable
  10.  */
  11. class ProductMovie
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $link;
  23.     /**
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $position;
  27.     /**
  28.      * @ORM\Column(type="string", length=255, nullable=true)
  29.      * @var string
  30.      */
  31.     private $thumbnail;
  32.     /**
  33.      * @Vich\UploadableField(mapping="product_images", fileNameProperty="thumbnail")
  34.      * @Assert\File(
  35.      *     maxSize = "2M",
  36.      *     maxSizeMessage = "File is too big, allowed maximum size is {{ limit }} {{ suffix }}"
  37.      * )
  38.      * @var File
  39.      */
  40.     private $thumbnailFile;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductAssociation", inversedBy="productMovies", cascade={"persist"})
  43.      * @ORM\JoinColumn(nullable=false)
  44.      */
  45.     private $productAssociation;
  46.     /**
  47.      * @ORM\Column(type="datetime", nullable=true)
  48.      * @var \DateTime
  49.      */
  50.     private $updatedAt;
  51.     /** @ORM\PreUpdate() */
  52.     public function preUpdate()
  53.     {
  54.         $this->updatedAt = new \DateTime('now');
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getLink(): ?string
  61.     {
  62.         return $this->link;
  63.     }
  64.     public function setLink(string $link): self
  65.     {
  66.         $this->link $link;
  67.         return $this;
  68.     }
  69.     public function getPosition(): ?int
  70.     {
  71.         return $this->position;
  72.     }
  73.     public function setPosition(int $position): self
  74.     {
  75.         $this->position $position;
  76.         return $this;
  77.     }
  78.     public function setThumbnailFile(File $thumbnailFile null)
  79.     {
  80.         $this->thumbnailFile $thumbnailFile;
  81.         // VERY IMPORTANT:
  82.         // It is required that at least one field changes if you are using Doctrine,
  83.         // otherwise the event listeners won't be called and the file is lost
  84.         if ($thumbnailFile)
  85.         {
  86.             // if 'updatedAt' is not defined in your entity, use another property
  87.             $this->updatedAt = new \DateTime('now');
  88.         }
  89.     }
  90.     public function getThumbnailFile()
  91.     {
  92.         return $this->thumbnailFile;
  93.     }
  94.     public function setThumbnail($thumbnail)
  95.     {
  96.         $this->thumbnail $thumbnail;
  97.     }
  98.     public function getThumbnail()
  99.     {
  100.         return $this->thumbnail;
  101.     }
  102.     public function getUpdatedAt(): ?\DateTimeInterface
  103.     {
  104.         return $this->updatedAt;
  105.     }
  106.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  107.     {
  108.         $this->updatedAt $updatedAt;
  109.         return $this;
  110.     }
  111.     public function getProductAssociation(): ?ProductAssociation
  112.     {
  113.         return $this->productAssociation;
  114.     }
  115.     public function setProductAssociation(?ProductAssociation $productAssociation): self
  116.     {
  117.         $this->productAssociation $productAssociation;
  118.         return $this;
  119.     }
  120. }