src/Entity/GroupTicket/PublicConnection.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\GroupTicket;
  3. use App\Entity\Abstract\Entity;
  4. use App\Entity\User;
  5. use App\Repository\GroupTicket\PublicConnectionRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClass: PublicConnectionRepository::class)]
  10. #[ORM\Table(name: 'group_tickets_public_connection')]
  11. class PublicConnection extends Entity
  12. {
  13. #[ORM\Id]
  14. #[ORM\GeneratedValue]
  15. #[ORM\Column]
  16. private ?int $id = null;
  17. #[ORM\Column(length: 255)]
  18. private ?string $name = null;
  19. #[ORM\OneToMany(mappedBy: 'publicConnection', targetEntity: PriceList::class, cascade: ["all"])]
  20. private Collection $priceLists;
  21. #[ORM\ManyToMany(targetEntity: TransportCompany::class, mappedBy: 'publicConnections')]
  22. private Collection $transportCompanies;
  23. #[ORM\Column(nullable: true)]
  24. private ?int $restriktion = null;
  25. #[ORM\Column(length: 255, nullable: true)]
  26. private ?string $template = null;
  27. #[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'groupTicketPublicConnection')]
  28. private Collection $users;
  29. #[ORM\Column(length: 20, nullable: true)]
  30. private ?string $groupTicketMode = null;
  31. public function __construct()
  32. {
  33. $this->priceLists = new ArrayCollection();
  34. $this->transportCompanies = new ArrayCollection();
  35. $this->users = new ArrayCollection();
  36. }
  37. public function getGroupTicketMode(): ?string
  38. {
  39. return $this->groupTicketMode;
  40. }
  41. public function setGroupTicketMode(?string $groupTicketMode): static
  42. {
  43. $this->groupTicketMode = $groupTicketMode;
  44. return $this;
  45. }
  46. public function getId(): ?int
  47. {
  48. return $this->id;
  49. }
  50. public function getName(): ?string
  51. {
  52. return $this->name;
  53. }
  54. public function setName(string $name): static
  55. {
  56. $this->name = $name;
  57. return $this;
  58. }
  59. /**
  60. * @return Collection<int, PriceList>
  61. */
  62. public function getPriceLists(): Collection
  63. {
  64. return $this->priceLists;
  65. }
  66. public function addPriceList(PriceList $priceList): static
  67. {
  68. if (!$this->priceLists->contains($priceList)) {
  69. $this->priceLists->add($priceList);
  70. $priceList->setPublicConnection($this);
  71. }
  72. return $this;
  73. }
  74. public function removePriceList(PriceList $priceList): static
  75. {
  76. if ($this->priceLists->removeElement($priceList)) {
  77. // set the owning side to null (unless already changed)
  78. if ($priceList->getPublicConnection() === $this) {
  79. $priceList->setPublicConnection(null);
  80. }
  81. }
  82. return $this;
  83. }
  84. /**
  85. * @return Collection<int, TransportCompany>
  86. */
  87. public function getTransportCompanies(): Collection
  88. {
  89. return $this->transportCompanies;
  90. }
  91. public function addTransportCompany(TransportCompany $transportCompany): static
  92. {
  93. if (!$this->transportCompanies->contains($transportCompany)) {
  94. $this->transportCompanies->add($transportCompany);
  95. $transportCompany->addPublicConnection($this);
  96. }
  97. return $this;
  98. }
  99. public function removeTransportCompany(TransportCompany $transportCompany): static
  100. {
  101. if ($this->transportCompanies->removeElement($transportCompany)) {
  102. $transportCompany->removePublicConnection($this);
  103. }
  104. return $this;
  105. }
  106. public function getRestriktion(): ?int
  107. {
  108. return $this->restriktion;
  109. }
  110. public function getRestriktionLabelKey(): string
  111. {
  112. return match ($this->getRestriktion()) {
  113. 2 => 'rvbw',
  114. 3 => 'tvzg',
  115. default => '',
  116. };
  117. }
  118. public function setRestriktion(?int $restriktion): static
  119. {
  120. $this->restriktion = $restriktion;
  121. return $this;
  122. }
  123. public function getTemplate(): ?string
  124. {
  125. return $this->template;
  126. }
  127. public function setTemplate(?string $template): static
  128. {
  129. $this->template = $template;
  130. return $this;
  131. }
  132. /**
  133. * @return Collection<int, User>
  134. */
  135. public function getUsers(): Collection
  136. {
  137. return $this->users;
  138. }
  139. public function addUser(User $user): static
  140. {
  141. if (!$this->users->contains($user)) {
  142. $this->users->add($user);
  143. $user->addGroupTicketPublicConnection($this);
  144. }
  145. return $this;
  146. }
  147. public function removeUser(User $user): static
  148. {
  149. if ($this->users->removeElement($user)) {
  150. $user->removeGroupTicketPublicConnection($this);
  151. }
  152. return $this;
  153. }
  154. }