src/Entity/Galerie.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\GalerieRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. #[ORM\Entity(repositoryClassGalerieRepository::class)]
  11. #[Vich\Uploadable]
  12. class Galerie
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $titre null;
  20.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  21.     private ?\DateTimeInterface $date null;
  22.     #[ORM\Column(typeTypes::TEXTlength:10000)]
  23.     private ?string $description null;
  24.     // #[ORM\Column(type:'string', length:255)]
  25.     // private $image;
  26.     // #[Vich\UploadableField(mapping:'post_thumbnails', fileNameProperty:'image')]
  27.     // private $imageFile;
  28.     #[ORM\OneToMany(mappedBy'galerie'targetEntityImage::class, cascade: ['persist''remove'])]
  29.     private $images;
  30.     #[ORM\OneToMany(mappedBy'galerie'targetEntityVideo::class, cascade: ['persist''remove'])]
  31.     private $videos;
  32.     public function __construct()
  33.     {
  34.         $this->images = new ArrayCollection();
  35.         $this->videos = new ArrayCollection();
  36.     }
  37.     // #[ORM\Column(type:'datetime')]
  38.     // private $updatedAt;
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getTitre(): ?string
  44.     {
  45.         return $this->titre;
  46.     }
  47.     public function setTitre(string $titre): self
  48.     {
  49.         $this->titre $titre;
  50.         return $this;
  51.     }
  52.     public function getDate(): ?\DateTimeInterface
  53.     {
  54.         return $this->date;
  55.     }
  56.     public function setDate(\DateTimeInterface $date): self
  57.     {
  58.         $this->date $date;
  59.         return $this;
  60.     }
  61.     public function getDescription(): ?string
  62.     {
  63.         return $this->description;
  64.     }
  65.     public function setDescription(string $description): self
  66.     {
  67.         $this->description $description;
  68.         return $this;
  69.     }
  70.     // public function setImageFile(File $image = null)
  71.     // {
  72.     //     $this->imageFile = $image;
  73.     //     // VERY IMPORTANT:
  74.     //     // It is required that at least one field changes if you are using Doctrine,
  75.     //     // otherwise the event listeners won't be called and the file is lost
  76.     //   //  if ($image) {
  77.     //         // if 'updatedAt' is not defined in your entity, use another property
  78.     //        // $this->updatedAt = new \DateTime('now');
  79.     //    // }
  80.     // }
  81.     // public function getImageFile()
  82.     // {
  83.     //     return $this->imageFile;
  84.     // }
  85.     // public function setImage($image)
  86.     // {
  87.     //     $this->image = $image;
  88.     // }
  89.     // public function getImage()
  90.     // {
  91.     //     return $this->image;
  92.     // }
  93.     /**
  94.      * @return Collection<int, Image>
  95.      */
  96.     public function getImages(): Collection
  97.     {
  98.         return $this->images;
  99.     }
  100.     public function addImage(Image $image): ?self
  101.     {
  102.         if (!$this->images->contains($image)) {
  103.             $this->images->add($image);
  104.             $image->setGalerie($this);
  105.         }
  106.         return $this;
  107.     }
  108.     public function removeImage(Image $image): self
  109.     {
  110.         if ($this->images->removeElement($image)) {
  111.             // set the owning side to null (unless already changed)
  112.             if ($image->getGalerie() === $this) {
  113.                 $image->setGalerie(null);
  114.             }
  115.         }
  116.         return $this;
  117.     }
  118.     ////
  119.      /**
  120.      * @return Collection<int, Video>
  121.      */
  122.     public function getVideos(): Collection
  123.     {
  124.         return $this->videos;
  125.     }
  126.     public function addVideo(?Video $video): self
  127.     {
  128.         if (!$this->images->contains($video)) {
  129.             $this->images->add($video);
  130.             $video->setGalerie($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeVideo(?Video $video): self
  135.     {
  136.         if ($this->images->removeElement($video)) {
  137.             // set the owning side to null (unless already changed)
  138.             if ($video->getGalerie() === $this) {
  139.                 $video->setGalerie(null);
  140.             }
  141.         }
  142.         return $this;
  143.     }
  144.     public function __toString()
  145.     {
  146.         return (string) $this->id;
  147.     }
  148. }