<?php
namespace App\Entity\Gos;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProductMovieRepository")
* @Vich\Uploadable
*/
class ProductMovie
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $link;
/**
* @ORM\Column(type="integer")
*/
private $position;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @var string
*/
private $thumbnail;
/**
* @Vich\UploadableField(mapping="product_images", fileNameProperty="thumbnail")
* @Assert\File(
* maxSize = "2M",
* maxSizeMessage = "File is too big, allowed maximum size is {{ limit }} {{ suffix }}"
* )
* @var File
*/
private $thumbnailFile;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductAssociation", inversedBy="productMovies", cascade={"persist"})
* @ORM\JoinColumn(nullable=false)
*/
private $productAssociation;
/**
* @ORM\Column(type="datetime", nullable=true)
* @var \DateTime
*/
private $updatedAt;
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime('now');
}
public function getId(): ?int
{
return $this->id;
}
public function getLink(): ?string
{
return $this->link;
}
public function setLink(string $link): self
{
$this->link = $link;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
public function setThumbnailFile(File $thumbnailFile = null)
{
$this->thumbnailFile = $thumbnailFile;
// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($thumbnailFile)
{
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}
public function getThumbnailFile()
{
return $this->thumbnailFile;
}
public function setThumbnail($thumbnail)
{
$this->thumbnail = $thumbnail;
}
public function getThumbnail()
{
return $this->thumbnail;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getProductAssociation(): ?ProductAssociation
{
return $this->productAssociation;
}
public function setProductAssociation(?ProductAssociation $productAssociation): self
{
$this->productAssociation = $productAssociation;
return $this;
}
}