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.

78 lines
2.0KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Model\User;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
  7. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  8. use Lc\CaracoleBundle\Model\Section\OpeningInterface;
  9. use Lc\SovBundle\Model\User\GroupUserModel as SovGroupUserModel;
  10. /**
  11. * @ORM\MappedSuperclass()
  12. */
  13. abstract class GroupUserModel extends SovGroupUserModel 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\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Section\OpeningInterface", mappedBy="groupUser")
  22. */
  23. protected $openings;
  24. public function __construct()
  25. {
  26. parent::__construct();
  27. $this->openings = new ArrayCollection();
  28. }
  29. public function getMerchant(): MerchantInterface
  30. {
  31. return $this->merchant;
  32. }
  33. public function setMerchant(MerchantInterface $merchant): self
  34. {
  35. $this->merchant = $merchant;
  36. return $this;
  37. }
  38. /**
  39. * @return Collection|OpeningInterface[]
  40. */
  41. public function getOpenings(): Collection
  42. {
  43. return $this->openings;
  44. }
  45. public function addOpening(OpeningInterface $opening): self
  46. {
  47. if (!$this->openings->contains($opening)) {
  48. $this->openings[] = $opening;
  49. $opening->setGroupUser($this);
  50. }
  51. return $this;
  52. }
  53. public function removeOpening(OpeningInterface $opening): self
  54. {
  55. if ($this->openings->removeElement($opening)) {
  56. // set the owning side to null (unless already changed)
  57. if ($opening->getGroupUser() === $this) {
  58. $opening->setGroupUser(null);
  59. }
  60. }
  61. return $this;
  62. }
  63. }