Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

83 linhas
1.8KB

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