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.

80 linhas
1.7KB

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