src/Entity/MediaBlock.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MediaBlockRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Utils\Utils;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. /**
  14.  * @ORM\Entity(repositoryClass=MediaBlockRepository::class)
  15.  * @Vich\Uploadable 
  16.  */
  17. class MediaBlock
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     private $image;
  29.     /**
  30.      * @ORM\Column(type="integer", nullable=true)
  31.      */
  32.     private $position;
  33.     /**
  34.      * @Gedmo\Timestampable(on="create")
  35.      * @ORM\Column(type="datetime", nullable=true)
  36.      */
  37.     private $created_at;
  38.     /**
  39.      * @Gedmo\Timestampable(on="update")
  40.      * @ORM\Column(type="datetime", nullable=true)
  41.      */
  42.     private $updated_at;
  43.     /**
  44.      * @Vich\UploadableField(mapping="image_media_block", fileNameProperty="image")
  45.      * @var File
  46.      */
  47.     private $imageFile;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private $lien;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity=Block::class, inversedBy="medias", cascade={"persist"})
  54.      */
  55.     private $block;
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getImage(): ?string
  61.     {
  62.         return $this->image;
  63.     }
  64.     public function setImage(string $image): self
  65.     {
  66.         $this->image $image;
  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 getCreatedAt(): ?\DateTimeInterface
  79.     {
  80.         return $this->created_at;
  81.     }
  82.     public function setCreatedAt(?\DateTimeInterface $created_at): self
  83.     {
  84.         $this->created_at $created_at;
  85.         return $this;
  86.     }
  87.     public function getUpdatedAt(): ?\DateTimeInterface
  88.     {
  89.         return $this->updated_at;
  90.     }
  91.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  92.     {
  93.         $this->updated_at $updated_at;
  94.         return $this;
  95.     }
  96.     public function getLien(): ?string
  97.     {
  98.         return $this->lien;
  99.     }
  100.     public function setLien(?string $lien): self
  101.     {
  102.         $this->lien $lien;
  103.         return $this;
  104.     }
  105.     
  106.     public function setImageFile(File $image null)
  107.     {
  108.         $this->imageFile $image;
  109.         if ($image) {
  110.             $this->updated_at = new \DateTime('now');
  111.         }
  112.         return $this;
  113.     }
  114.     public function getImageFile()
  115.     {
  116.         return $this->imageFile;
  117.     }
  118.     public function getBlock(): ?Block
  119.     {
  120.         return $this->block;
  121.     }
  122.     public function setBlock(?Block $block): self
  123.     {
  124.         $this->block $block;
  125.         return $this;
  126.     }
  127. }