src/Entity/Sponsor.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Eventable\EventableTrait;
  4. use App\Entity\Sortable\Sortable;
  5. use App\Entity\Sortable\SortableInterface;
  6. use App\Repository\SponsorRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Uid\Uuid;
  11. /**
  12.  * @ORM\Entity(repositoryClass=SponsorRepository::class)
  13.  */
  14. class Sponsor implements SortableInterface
  15. {
  16.     use Sortable;
  17.     const TYPE_SPONSOR 'sponsor';
  18.     const TYPE_PARTNER 'partner';
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\Column(type="uuid", unique=true)
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $name;
  28.     /**
  29.      * @ORM\Column(type="text", nullable=true)
  30.      */
  31.     private $description;
  32.     /**
  33.      * @ORM\ManyToMany(targetEntity=Image::class, cascade={"persist", "remove"}, orphanRemoval=true)
  34.      */
  35.     private $images;
  36.     /**
  37.      * @ORM\Column(type="enumsponsortype")
  38.      */
  39.     private $type;
  40.     /**
  41.      * @ORM\ManyToMany(targetEntity=Event::class, inversedBy="sponsors")
  42.      */
  43.     private $events;
  44.     public function __construct()
  45.     {
  46.         $this->id Uuid::v4();
  47.         $this->images = new ArrayCollection();
  48.         $this->events = new ArrayCollection();
  49.     }
  50.     public function getId(): Uuid
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getName(): ?string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function setName(string $name): self
  59.     {
  60.         $this->name $name;
  61.         return $this;
  62.     }
  63.     public function getDescription(): ?string
  64.     {
  65.         return $this->description;
  66.     }
  67.     public function setDescription(?string $description): self
  68.     {
  69.         $this->description $description;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection<int, Image>
  74.      */
  75.     public function getImages(): Collection
  76.     {
  77.         return $this->images;
  78.     }
  79.     public function addImage(Image $image): self
  80.     {
  81.         if (!$this->images->contains($image)) {
  82.             $this->images[] = $image;
  83.         }
  84.         return $this;
  85.     }
  86.     public function removeImage(Image $image): self
  87.     {
  88.         $this->images->removeElement($image);
  89.         return $this;
  90.     }
  91.     public function getType()
  92.     {
  93.         return $this->type;
  94.     }
  95.     public function setType($type): self
  96.     {
  97.         $this->type $type;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, Event>
  102.      */
  103.     public function getEvents(): Collection
  104.     {
  105.         return $this->events;
  106.     }
  107.     public function addEvent(Event $event): self
  108.     {
  109.         if (!$this->events->contains($event)) {
  110.             $this->events[] = $event;
  111.         }
  112.         return $this;
  113.     }
  114.     public function removeEvent(Event $event): self
  115.     {
  116.         $this->events->removeElement($event);
  117.         return $this;
  118.     }
  119. }