<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\VideoRepository")
*/
class Video
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $libelle;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="integer")
*/
private $type;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $youtube;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $file;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $taille;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $thumbnail;
/**
* @ORM\Column(type="boolean")
*/
private $premium;
/**
* @ORM\Column(type="boolean")
*/
private $status;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updated_at;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="videos")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $vimeo;
/**
* @ORM\ManyToOne(targetEntity=CategorieVideo::class, inversedBy="video")
*/
private $categorie;
/**
* @ORM\Column(type="boolean")
*/
private $une;
/**
* @ORM\OneToMany(targetEntity=VideoVisit::class, mappedBy="video")
*/
private $visits;
const type_full=['Youtube','Fichier','Vimeo'];
public function getFullType(){
return self::type_full[$this->type];
}
public function getYoutubeId(){
return str_replace(['https://','http://','www.','embed','/','youtube.com','watch','?','v='],'',$this->youtube);
}
public function __construct()
{
$this->created_at=new \DateTime();
$this->status=false;
$this->une=false;
$this->visits = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function setLibelle(string $libelle): self
{
$this->libelle = $libelle;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getYoutube(): ?string
{
return $this->youtube;
}
public function setYoutube(?string $youtube): self
{
$this->youtube = $youtube;
return $this;
}
public function getFile(): ?string
{
return $this->file;
}
public function setFile(?string $file): self
{
$this->file = $file;
return $this;
}
public function getTaille(): ?int
{
return $this->taille;
}
public function setTaille(?int $taille): self
{
$this->taille = $taille;
return $this;
}
public function getThumbnail(): ?string
{
return $this->thumbnail;
}
public function setThumbnail(?string $thumbnail): self
{
$this->thumbnail = $thumbnail;
return $this;
}
public function getPremium(): ?bool
{
return $this->premium;
}
public function setPremium(bool $premium): self
{
$this->premium = $premium;
return $this;
}
public function getStatus(): ?bool
{
return $this->status;
}
public function setStatus(bool $status): self
{
$this->status = $status;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(?\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getVimeo(): ?string
{
return $this->vimeo;
}
public function setVimeo(?string $vimeo): self
{
$this->vimeo = $vimeo;
return $this;
}
public function getCategorie(): ?CategorieVideo
{
return $this->categorie;
}
public function setCategorie(?CategorieVideo $categorie): self
{
$this->categorie = $categorie;
return $this;
}
public function getUne(): ?bool
{
return $this->une;
}
public function setUne(bool $une): self
{
$this->une = $une;
return $this;
}
/**
* @return Collection<int, VideoVisit>
*/
public function getVisits(): Collection
{
return $this->visits;
}
public function addVisit(VideoVisit $visit): self
{
if (!$this->visits->contains($visit)) {
$this->visits[] = $visit;
$visit->setVideo($this);
}
return $this;
}
public function removeVisit(VideoVisit $visit): self
{
if ($this->visits->removeElement($visit)) {
// set the owning side to null (unless already changed)
if ($visit->getVideo() === $this) {
$visit->setVideo(null);
}
}
return $this;
}
}