Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

76 Zeilen
1.5KB

  1. <?php
  2. namespace Lc\SovBundle\Model\User;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Lc\SovBundle\Doctrine\EntityInterface;
  7. use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
  8. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  9. /**
  10. * @ORM\MappedSuperclass()
  11. */
  12. abstract class GroupUserModel extends AbstractFullEntity implements GroupUserInterface, EntityInterface
  13. {
  14. /**
  15. * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", mappedBy="groupUsers")
  16. */
  17. protected $users;
  18. public function __toString()
  19. {
  20. return $this->getTitle();
  21. }
  22. public function __construct()
  23. {
  24. $this->users = new ArrayCollection();
  25. }
  26. public function getTitle(): ?string
  27. {
  28. return $this->title;
  29. }
  30. public function setTitle(string $title): self
  31. {
  32. $this->title = $title;
  33. return $this;
  34. }
  35. public function addUser(UserInterface $user): self
  36. {
  37. if (!$this->users->contains($user)) {
  38. $this->users[] = $user;
  39. }
  40. return $this;
  41. }
  42. /**
  43. * @return Collection|UserInterface[]
  44. */
  45. public function getUsers(): Collection
  46. {
  47. return $this->users;
  48. }
  49. public function removeUser(UserInterface $user): self
  50. {
  51. if ($this->users->contains($user)) {
  52. $this->users->removeElement($user);
  53. }
  54. return $this;
  55. }
  56. }