Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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