Commit e8c9e324 authored by Andreas Heimann's avatar Andreas Heimann

add playlist entity

parent f9c89e6f
...@@ -118,10 +118,16 @@ class Song ...@@ -118,10 +118,16 @@ class Song
*/ */
private $spinPlays; private $spinPlays;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\SongPlaylist", mappedBy="songs")
*/
private $songPlaylists;
public function __construct() public function __construct()
{ {
$this->reviews = new ArrayCollection(); $this->reviews = new ArrayCollection();
$this->spinPlays = new ArrayCollection(); $this->spinPlays = new ArrayCollection();
$this->songPlaylists = new ArrayCollection();
} }
public function getId(): ?int public function getId(): ?int
...@@ -437,4 +443,32 @@ class Song ...@@ -437,4 +443,32 @@ class Song
return $response; return $response;
} }
/**
* @return Collection|SongPlaylist[]
*/
public function getSongPlaylists(): Collection
{
return $this->songPlaylists;
}
public function addSongPlaylist(SongPlaylist $songPlaylist): self
{
if (!$this->songPlaylists->contains($songPlaylist)) {
$this->songPlaylists[] = $songPlaylist;
$songPlaylist->addSong($this);
}
return $this;
}
public function removeSongPlaylist(SongPlaylist $songPlaylist): self
{
if ($this->songPlaylists->contains($songPlaylist)) {
$this->songPlaylists->removeElement($songPlaylist);
$songPlaylist->removeSong($this);
}
return $this;
}
} }
<?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\SongPlaylistRepository")
*/
class SongPlaylist
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255)
*/
private $fileReference;
/**
* @ORM\Column(type="boolean")
*/
private $isOfficial;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Song", inversedBy="songPlaylists")
*/
private $songs;
public function __construct()
{
$this->songs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getFileReference(): ?string
{
return $this->fileReference;
}
public function setFileReference(string $fileReference): self
{
$this->fileReference = $fileReference;
return $this;
}
public function getIsOfficial(): ?bool
{
return $this->isOfficial;
}
public function setIsOfficial(bool $isOfficial): self
{
$this->isOfficial = $isOfficial;
return $this;
}
/**
* @return Collection|Song[]
*/
public function getSongs(): Collection
{
return $this->songs;
}
public function addSong(Song $song): self
{
if (!$this->songs->contains($song)) {
$this->songs[] = $song;
}
return $this;
}
public function removeSong(Song $song): self
{
if ($this->songs->contains($song)) {
$this->songs->removeElement($song);
}
return $this;
}
}
<?php
namespace App\Repository;
use App\Entity\SongPlaylist;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method SongPlaylist|null find($id, $lockMode = null, $lockVersion = null)
* @method SongPlaylist|null findOneBy(array $criteria, array $orderBy = null)
* @method SongPlaylist[] findAll()
* @method SongPlaylist[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SongPlaylistRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, SongPlaylist::class);
}
// /**
// * @return SongPlaylist[] Returns an array of SongPlaylist objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('s')
->andWhere('s.exampleField = :val')
->setParameter('val', $value)
->orderBy('s.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?SongPlaylist
{
return $this->createQueryBuilder('s')
->andWhere('s.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment