src/Entity/Formation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FormationRepository;
  4. use DateTimeInterface;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=FormationRepository::class)
  10.  */
  11. class Formation
  12. {
  13.     /**
  14.      * Début de chemin vers les images
  15.      */
  16.     private const CHEMINIMAGE "https://i.ytimg.com/vi/";
  17.     
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="datetime", nullable=true)
  26.      */
  27.     private $publishedAt;
  28.     /**
  29.      * @ORM\Column(type="string", length=100, nullable=true)
  30.      */
  31.     private $title;
  32.     /**
  33.      * @ORM\Column(type="text", nullable=true)
  34.      */
  35.     private $description;
  36.     /**
  37.      * @ORM\Column(type="string", length=20, nullable=true)
  38.      */
  39.     private $videoId;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity=Playlist::class, inversedBy="formations")
  42.      */
  43.     private $playlist;
  44.     /**
  45.      * @ORM\ManyToMany(targetEntity=Categorie::class, inversedBy="formations")
  46.      */
  47.     private $categories;
  48.     public function __construct()
  49.     {
  50.         $this->categories = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getPublishedAt(): ?DateTimeInterface
  57.     {
  58.         return $this->publishedAt;
  59.     }
  60.     public function setPublishedAt(?DateTimeInterface $publishedAt): self
  61.     {
  62.         $this->publishedAt $publishedAt;
  63.         return $this;
  64.     }
  65.     
  66.     public function getPublishedAtString(): string
  67.     {
  68.         if ($this->publishedAt == null) {
  69.             return "";
  70.         }
  71.         return $this->publishedAt->format('d/m/Y');
  72.     }
  73.     public function getTitle(): ?string
  74.     {
  75.         return $this->title;
  76.     }
  77.     public function setTitle(?string $title): self
  78.     {
  79.         $this->title $title;
  80.         return $this;
  81.     }
  82.     public function getDescription(): ?string
  83.     {
  84.         return $this->description;
  85.     }
  86.     public function __toString()
  87.     {
  88.         return $this->title;
  89.     }
  90.     public function setDescription(?string $description): self
  91.     {
  92.         $this->description $description;
  93.         return $this;
  94.     }
  95.     public function getMiniature(): ?string
  96.     {
  97.         return self::CHEMINIMAGE.$this->videoId."/default.jpg";
  98.     }
  99.     public function getPicture(): ?string
  100.     {
  101.         return self::CHEMINIMAGE.$this->videoId."/hqdefault.jpg";
  102.     }
  103.     public function getVideoId(): ?string
  104.     {
  105.         return $this->videoId;
  106.     }
  107.     public function setVideoId(?string $videoId): self
  108.     {
  109.         $this->videoId $videoId;
  110.         return $this;
  111.     }
  112.     public function getPlaylist(): ?Playlist
  113.     {
  114.         return $this->playlist;
  115.     }
  116.     public function setPlaylist(?Playlist $playlist): self
  117.     {
  118.         $this->playlist $playlist;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return Collection<int, Categorie>
  123.      */
  124.     public function getCategories(): Collection
  125.     {
  126.         return $this->categories;
  127.     }
  128.     public function addCategory(Categorie $category): self
  129.     {
  130.         if (!$this->categories->contains($category)) {
  131.             $this->categories[] = $category;
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeCategory(Categorie $category): self
  136.     {
  137.         $this->categories->removeElement($category);
  138.         return $this;
  139.     }
  140. }