You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.2 KiB

<?php
namespace App\Entity;
use App\Repository\ReleaseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ReleaseRepository::class)]
class Release
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\ManyToMany(targetEntity: Artist::class, inversedBy: 'releases')]
private Collection $artists;
#[ORM\ManyToOne(inversedBy: 'releases')]
#[ORM\JoinColumn(nullable: false)]
private ?User $owner = null;
#[ORM\OneToOne(mappedBy: 'release', cascade: ['persist', 'remove'])]
private ?ReleaseMetadata $metadata = null;
public function __construct()
{
$this->artists = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): static
{
$this->title = $title;
return $this;
}
/**
* @return Collection<int, Artist>
*/
public function getArtists(): Collection
{
return $this->artists;
}
public function addArtist(Artist $artist): static
{
if (!$this->artists->contains($artist)) {
$this->artists->add($artist);
}
return $this;
}
public function removeArtist(Artist $artist): static
{
$this->artists->removeElement($artist);
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): static
{
$this->owner = $owner;
return $this;
}
public function getMetadata(): ?ReleaseMetadata
{
return $this->metadata;
}
public function setMetadata(ReleaseMetadata $metadata): static
{
// set the owning side of the relation if necessary
if ($metadata->getRelease() !== $this) {
$metadata->setRelease($this);
}
$this->metadata = $metadata;
return $this;
}
}