src/Entity/Status.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StatusRepository;
  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: StatusRepository::class)]
  9. class Status
  10. {
  11. public function __construct(
  12. #[ORM\Id]
  13. #[ORM\Column(type:"string", length:36)]
  14. private ?string $id = null,
  15. #[ORM\Column(type:"string")]
  16. private ?string $name = null,
  17. #[ORM\Column(type:"string")]
  18. private ?string $colour = null,
  19. #[ORM\Column(type:"boolean", options: ['default' => false])]
  20. private bool $isDefault = false,
  21. #[ORM\Column(type:"boolean", options: ['default' => false])]
  22. private bool $isClose = false,
  23. #[ORM\OneToMany(mappedBy: 'status', targetEntity: Ticket::class)]
  24. private ?Collection $tickets = null,
  25. ) {
  26. $this->id = $this->id ?? Uuid::v4()->toRfc4122();
  27. $this->tickets = $this->tickets ?? new ArrayCollection();
  28. }
  29. /**
  30. * @return string|null
  31. */
  32. public function getId(): ?string
  33. {
  34. return $this->id;
  35. }
  36. /**
  37. * @return string|null
  38. */
  39. public function getName(): ?string
  40. {
  41. return $this->name;
  42. }
  43. /**
  44. * @param string $name
  45. * @return $this
  46. */
  47. public function setName(string $name): self
  48. {
  49. $this->name = $name;
  50. return $this;
  51. }
  52. /**
  53. * @return string|null
  54. */
  55. public function getColour(): ?string
  56. {
  57. return $this->colour;
  58. }
  59. /**
  60. * @param string|null $colour
  61. */
  62. public function setColour(?string $colour): void
  63. {
  64. $this->colour = $colour;
  65. }
  66. /**
  67. * @return bool
  68. */
  69. public function getIsDefault(): bool
  70. {
  71. return $this->isDefault;
  72. }
  73. /**
  74. * @param bool $isDefault
  75. */
  76. public function setIsDefault(bool $isDefault): void
  77. {
  78. $this->isDefault = $isDefault;
  79. }
  80. /**
  81. * @return bool
  82. */
  83. public function getIsClose(): bool
  84. {
  85. return $this->isClose;
  86. }
  87. /**
  88. * @param bool $isClose
  89. */
  90. public function setIsClose(bool $isClose): void
  91. {
  92. $this->isClose = $isClose;
  93. }
  94. /**
  95. * @return Collection<int, Ticket>|null
  96. */
  97. public function getTickets(): ?Collection
  98. {
  99. return $this->tickets;
  100. }
  101. public function addTicket(Ticket $ticket): self
  102. {
  103. if ($this->tickets && !$this->tickets->contains($ticket)) {
  104. $this->tickets->add($ticket);
  105. $ticket->setStatus($this);
  106. }
  107. return $this;
  108. }
  109. public function removeTicket(Ticket $ticket): self
  110. {
  111. if ($this->tickets && $this->tickets->contains($ticket)) {
  112. // set the owning side to null (unless already changed)
  113. $this->tickets->removeElement($ticket);
  114. if ($ticket->getStatus() === $this) {
  115. $ticket->setStatus(null);
  116. }
  117. }
  118. return $this;
  119. }
  120. }