src/Entity/Priority.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PriorityRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Uid\Uuid;
  8. #[ORM\Entity(repositoryClass: PriorityRepository::class)]
  9. class Priority
  10. {
  11. #[ORM\Id]
  12. #[ORM\Column(type:"string", length:36)]
  13. private ?string $id = null;
  14. #[ORM\Column(type:"text")]
  15. private ?string $name = null;
  16. #[ORM\OneToMany(mappedBy: 'priority', targetEntity: Ticket::class)]
  17. private Collection $tickets;
  18. public function __construct($name)
  19. {
  20. $this->id = Uuid::v4()->toRfc4122();
  21. $this->name = $name;
  22. $this->tickets = new ArrayCollection();
  23. }
  24. public function getId(): ?string
  25. {
  26. return $this->id;
  27. }
  28. public function getName(): ?string
  29. {
  30. return $this->name;
  31. }
  32. public function setName(string $name): self
  33. {
  34. $this->name = $name;
  35. return $this;
  36. }
  37. /**
  38. * @return Collection<int, Ticket>
  39. */
  40. public function getTickets(): Collection
  41. {
  42. return $this->tickets;
  43. }
  44. public function addTicket(Ticket $ticket): self
  45. {
  46. if (!$this->tickets->contains($ticket)) {
  47. $this->tickets->add($ticket);
  48. $ticket->setPriority($this);
  49. }
  50. return $this;
  51. }
  52. public function removeTicket(Ticket $ticket): self
  53. {
  54. if ($this->tickets->removeElement($ticket)) {
  55. // set the owning side to null (unless already changed)
  56. if ($ticket->getPriority() === $this) {
  57. $ticket->setPriority(null);
  58. }
  59. }
  60. return $this;
  61. }
  62. }