You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.4KB

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