Links beetween Type/Categorie/Pays <-> Video

This commit is contained in:
Simon Vieille 2015-04-07 19:56:16 +02:00
commit d3157e7517
3 changed files with 177 additions and 1 deletions

View file

@ -12,6 +12,11 @@ class Categorie
*/
protected $lib;
/**
* @var mixed[] $videos Vidéos
*/
protected $videos = [];
/**
* @param string $lib Lib de la catégorie
*/
@ -61,4 +66,55 @@ class Categorie
{
return $this->lib;
}
/**
* @param Video $video
* @return boolean La catégorie est associé à la vidéo
*/
public function hasVideo(Video $video)
{
foreach ($this->getVideos() as $p) {
if ($p === $video) {
return true;
}
}
return false;
}
/**
* @return Type
*/
public function addVideo(Video $video)
{
if ($this->hasVideo($video)) {
return $this;
}
$video->addCategorie($this);
$this->videos[] = $video;
return $this;
}
/**
* @param mixed[] $videos
* @return Type
*/
public function setVideos(array $videos)
{
$this->videos = [];
foreach ($this->getVideos() as $v) {
$this->addVideo($v);
}
return $this;
}
public function getVideos()
{
return $this->videos;
}
}

View file

@ -22,6 +22,11 @@ class Pays
*/
protected $participants = [];
/**
* @var mixed[] $videos Vidéos
*/
protected $videos = [];
/**
* @param string $nom Nom du pays
* @param string $symbole Symbole du pays
@ -111,6 +116,10 @@ class Pays
}
}
if ($this !== $participant->getPays()) {
$participant->setPays($this);
}
$this->participants[] = $participant;
return $this;
@ -122,7 +131,11 @@ class Pays
*/
public function setParticipants(array $participants)
{
$this->participants = $participants;
$this->participants = [];
foreach ($participants as $participant) {
$this->addParticipant($participant);
}
return $this;
}
@ -131,4 +144,55 @@ class Pays
{
return $this->participants;
}
/**
* @param Video $video
* @return boolean Le pays est associé à la vidéo
*/
public function hasVideo(Video $video)
{
foreach ($this->getVideos() as $p) {
if ($p === $video) {
return true;
}
}
return false;
}
/**
* @return Pays
*/
public function addVideo(Video $video)
{
if ($this->hasVideo($video)) {
return $this;
}
$video->addPays($this);
$this->videos[] = $video;
return $this;
}
/**
* @param mixed[] $videos
* @return Pays
*/
public function setVideos(array $videos)
{
$this->videos = [];
foreach ($this->getVideos() as $v) {
$this->addVideo($v);
}
return $this;
}
public function getVideos()
{
return $this->videos;
}
}

View file

@ -12,6 +12,11 @@ class Type
*/
protected $lib;
/**
* @var mixed[] $videos Vidéos
*/
protected $videos = [];
/**
* @param string $lib Lib du type
*/
@ -61,4 +66,55 @@ class Type
{
return $this->lib;
}
/**
* @param Video $video
* @return boolean Le type est associé à la vidéo
*/
public function hasVideo(Video $video)
{
foreach ($this->getVideos() as $p) {
if ($p === $video) {
return true;
}
}
return false;
}
/**
* @return Type
*/
public function addVideo(Video $video)
{
if ($this->hasVideo($video)) {
return $this;
}
$video->addType($this);
$this->videos[] = $video;
return $this;
}
/**
* @param mixed[] $videos
* @return Type
*/
public function setVideos(array $videos)
{
$this->videos = [];
foreach ($this->getVideos() as $v) {
$this->addVideo($v);
}
return $this;
}
public function getVideos()
{
return $this->videos;
}
}