src/Entity/Artist.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Sortable\Sortable;
  4. use App\Entity\Sortable\SortableInterface;
  5. use App\Repository\ArtistRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Uid\Uuid;
  10. /**
  11.  * @ORM\Entity(repositoryClass=ArtistRepository::class)
  12.  * @ORM\Table(indexes={@ORM\Index(name="name_idx", columns={"name"})})
  13.  */
  14. class Artist implements SortableInterface
  15. {
  16.     use Sortable;
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\Column(type="uuid", unique=true)
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\ManyToMany(targetEntity=Image::class, cascade={"persist", "remove"}, orphanRemoval=true)
  28.      */
  29.     private $images;
  30.     /**
  31.      * @ORM\Column(type="text", nullable=true)
  32.      */
  33.     private $description;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=Lineup::class, mappedBy="artist")
  36.      * @ORM\OrderBy({"startAt" = "ASC"})
  37.      */
  38.     private $lineups;
  39.     public function __construct()
  40.     {
  41.         $this->id Uuid::v4();
  42.         $this->images = new ArrayCollection();
  43.         $this->lineups = new ArrayCollection();
  44.     }
  45.     public function getId(): string
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getName(): ?string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(string $name): self
  54.     {
  55.         $this->name $name;
  56.         return $this;
  57.     }
  58.     /**
  59.      * @return Collection<int, Image>
  60.      */
  61.     public function getImages(): Collection
  62.     {
  63.         return $this->images;
  64.     }
  65.     public function addImage(Image $image): self
  66.     {
  67.         if (!$this->images->contains($image)) {
  68.             $this->images[] = $image;
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeImage(Image $image): self
  73.     {
  74.         $this->images->removeElement($image);
  75.         return $this;
  76.     }
  77.     public function getDescription(): ?string
  78.     {
  79.         return $this->description;
  80.     }
  81.     public function setDescription(?string $description): self
  82.     {
  83.         $this->description $description;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return Collection<int, Lineup>
  88.      */
  89.     public function getLineups(): Collection
  90.     {
  91.         return $this->lineups;
  92.     }
  93.     public function addLineup(Lineup $lineup): self
  94.     {
  95.         if (!$this->lineups->contains($lineup)) {
  96.             $this->lineups[] = $lineup;
  97.             $lineup->setArtist($this);
  98.         }
  99.         return $this;
  100.     }
  101.     public function removeLineup(Lineup $lineup): self
  102.     {
  103.         if ($this->lineups->removeElement($lineup)) {
  104.             // set the owning side to null (unless already changed)
  105.             if ($lineup->getArtist() === $this) {
  106.                 $lineup->setArtist(null);
  107.             }
  108.         }
  109.         return $this;
  110.     }
  111. }