您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

GroupUserModel.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. }