<?php
namespace App\Entity;
use App\Repository\SoundRepository;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: SoundRepository::class)]
#[Vich\Uploadable]
class Sound
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[Vich\UploadableField(mapping: 'sounds', fileNameProperty: 'picture')]
private ?File $imageFile = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $picture = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $file = null;
#[ORM\ManyToOne(inversedBy: 'sounds')]
private ?Instrument $instrument = null;
#[ORM\ManyToOne(inversedBy: 'sounds')]
private ?Artist $artist = null;
#[ORM\ManyToOne(inversedBy: 'sounds')]
private ?Player $player = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'soundsBookmarked')]
private Collection $users;
#[ORM\Column(nullable: true)]
private ?int $seekTo = null;
public function __construct()
{
$this->users = new ArrayCollection();
}
/**
* @return File|null
*/
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param File|null $imageFile
*/
public function setImageFile(?File $imageFile): void
{
$this->imageFile = $imageFile;
if (null !== $imageFile) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new DateTimeImmutable();
}
}
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 getPicture(): ?string
{
return $this->picture;
}
public function setPicture(?string $picture): self
{
$this->picture = $picture;
return $this;
}
public function getFile(): ?string
{
return $this->file;
}
public function setFile(?string $file): self
{
$this->file = $file;
return $this;
}
public function getInstrument(): ?Instrument
{
return $this->instrument;
}
public function setInstrument(?Instrument $instrument): self
{
$this->instrument = $instrument;
return $this;
}
public function getArtist(): ?Artist
{
return $this->artist;
}
public function setArtist(?Artist $artist): self
{
$this->artist = $artist;
return $this;
}
public function getPlayer(): ?Player
{
return $this->player;
}
public function setPlayer(?Player $player): self
{
$this->player = $player;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->addSoundsBookmarked($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
$user->removeSoundsBookmarked($this);
}
return $this;
}
public function getSeekTo(): ?int
{
return $this->seekTo;
}
public function setSeekTo(?int $seekTo): static
{
$this->seekTo = $seekTo;
return $this;
}
}