|
@@ -40,6 +40,12 @@ class MediaVideo
|
|
|
|
|
|
private $url;
|
|
private $url;
|
|
|
|
|
|
|
|
+ public function setFromTmdb(string $type, string $identif): void
|
|
|
|
+ {
|
|
|
|
+ $this->setType($type);
|
|
|
|
+ $this->setIdentif($identif);
|
|
|
|
+ }
|
|
|
|
+
|
|
public function getId(): ?int
|
|
public function getId(): ?int
|
|
{
|
|
{
|
|
return $this->id;
|
|
return $this->id;
|
|
@@ -47,17 +53,18 @@ class MediaVideo
|
|
|
|
|
|
public function getUrl(): ?string
|
|
public function getUrl(): ?string
|
|
{
|
|
{
|
|
- return $this->url;
|
|
|
|
|
|
+ return $this->url();
|
|
}
|
|
}
|
|
|
|
|
|
- public function setUrl($url): self
|
|
|
|
|
|
+ public function setUrl(string $url): self
|
|
{
|
|
{
|
|
$this->url = $url;
|
|
$this->url = $url;
|
|
|
|
+ $this->extractIdentif();
|
|
|
|
|
|
return $this;
|
|
return $this;
|
|
}
|
|
}
|
|
|
|
|
|
- public function setType($type): self
|
|
|
|
|
|
+ public function setType(string $type): self
|
|
{
|
|
{
|
|
$this->type = $type;
|
|
$this->type = $type;
|
|
|
|
|
|
@@ -69,7 +76,7 @@ class MediaVideo
|
|
return $this->type;
|
|
return $this->type;
|
|
}
|
|
}
|
|
|
|
|
|
- public function setIdentif($identif): self
|
|
|
|
|
|
+ public function setIdentif(string $identif): self
|
|
{
|
|
{
|
|
$this->identif = $identif;
|
|
$this->identif = $identif;
|
|
|
|
|
|
@@ -126,13 +133,13 @@ class MediaVideo
|
|
$this->setType('vimeo'); // signale qu’il s’agit d’une video vimeo et l’inscrit dans l’attribut $type
|
|
$this->setType('vimeo'); // signale qu’il s’agit d’une video vimeo et l’inscrit dans l’attribut $type
|
|
}
|
|
}
|
|
|
|
|
|
- #[ORM\PrePersist()] // Les trois événement suivant s’exécute avant que l’entité soit enregistée
|
|
|
|
- #[ORM\PreUpdate()]
|
|
|
|
- #[ORM\PreFlush()]
|
|
|
|
|
|
+ //#[ORM\PrePersist()] // Les trois événements suivant s’exécutent avant que l’entité soit enregistrée
|
|
|
|
+ //#[ORM\PreUpdate()]
|
|
|
|
+ //#[ORM\PreFlush()]
|
|
|
|
|
|
public function extractIdentif(): void
|
|
public function extractIdentif(): void
|
|
{
|
|
{
|
|
- $url = $this->getUrl(); // on récupère l’url
|
|
|
|
|
|
+ $url = $this->url; // on récupère l’url
|
|
|
|
|
|
if (preg_match("#^(http|https)://video.fdlibre.eu/#", $url)) // Si c'est peertube fdlibre
|
|
if (preg_match("#^(http|https)://video.fdlibre.eu/#", $url)) // Si c'est peertube fdlibre
|
|
{
|
|
{
|
|
@@ -158,7 +165,7 @@ class MediaVideo
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private function embedUrl()
|
|
|
|
|
|
+ public function embedUrl(): ?string
|
|
{
|
|
{
|
|
$control = $this->getType(); // on récupère le type de la vidéo
|
|
$control = $this->getType(); // on récupère le type de la vidéo
|
|
$id = strip_tags($this->getIdentif()); // on récupère son identifiant
|
|
$id = strip_tags($this->getIdentif()); // on récupère son identifiant
|
|
@@ -175,10 +182,12 @@ class MediaVideo
|
|
} else if ($control == 'peertube') {
|
|
} else if ($control == 'peertube') {
|
|
$embed = "https://video.fdlibre.eu/videos/embed/" . $id;
|
|
$embed = "https://video.fdlibre.eu/videos/embed/" . $id;
|
|
return $embed;
|
|
return $embed;
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private function url()
|
|
|
|
|
|
+ public function url(): ?string
|
|
{
|
|
{
|
|
$control = $this->getType(); // on récupère le type de la vidéo
|
|
$control = $this->getType(); // on récupère le type de la vidéo
|
|
$id = strip_tags($this->getIdentif()); // on récupère son identifiant
|
|
$id = strip_tags($this->getIdentif()); // on récupère son identifiant
|
|
@@ -195,11 +204,13 @@ class MediaVideo
|
|
} else if ($control == 'peertube') {
|
|
} else if ($control == 'peertube') {
|
|
$embed = "https://video.fdlibre.eu/videos/watch/" . $id;
|
|
$embed = "https://video.fdlibre.eu/videos/watch/" . $id;
|
|
return $embed;
|
|
return $embed;
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public function image()
|
|
|
|
|
|
+ public function image(): ?string
|
|
{
|
|
{
|
|
$control = $this->getType(); // on récupère le type de la vidéo
|
|
$control = $this->getType(); // on récupère le type de la vidéo
|
|
$id = strip_tags($this->getIdentif()); // on récupère son identifiant
|
|
$id = strip_tags($this->getIdentif()); // on récupère son identifiant
|
|
@@ -214,13 +225,15 @@ class MediaVideo
|
|
$hash = unserialize(file_get_contents("https://vimeo.com/api/v2/video/" . $id . ".php"));
|
|
$hash = unserialize(file_get_contents("https://vimeo.com/api/v2/video/" . $id . ".php"));
|
|
$image = $hash[0]['thumbnail_small'];
|
|
$image = $hash[0]['thumbnail_small'];
|
|
return $image;
|
|
return $image;
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public function video()
|
|
|
|
|
|
+ public function video(): string
|
|
{
|
|
{
|
|
- $video = "<iframe src='".$this->embedUrl()."' allowfullscreen></iframe>";
|
|
|
|
|
|
+ $video = "<iframe src='".$this->embedUrl()."' allowfullscreen></iframe>";
|
|
return $video;
|
|
return $video;
|
|
}
|
|
}
|
|
}
|
|
}
|