Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ReductionPropertyTrait.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace Lc\CaracoleBundle\Doctrine\Extension;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  7. use Lc\SovBundle\Model\User\GroupUserInterface;
  8. use Lc\SovBundle\Model\User\UserInterface;
  9. trait ReductionPropertyTrait
  10. {
  11. /**
  12. * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface")
  13. */
  14. protected $users;
  15. /**
  16. * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\GroupUserInterface")
  17. */
  18. protected $groupUsers;
  19. /**
  20. * @ORM\Column(type="datetime", nullable=true)
  21. */
  22. protected $dateStart;
  23. /**
  24. * @ORM\Column(type="datetime", nullable=true)
  25. */
  26. protected $dateEnd;
  27. /**
  28. * @ORM\Column(type="boolean")
  29. */
  30. protected $permanent;
  31. public function __construct()
  32. {
  33. $this->users = new ArrayCollection();
  34. $this->groupUsers = new ArrayCollection();
  35. }
  36. /**
  37. * @return Collection|UserInterface[]
  38. */
  39. public function getUsers(): Collection
  40. {
  41. return $this->users;
  42. }
  43. public function addUser(UserInterface $user): self
  44. {
  45. if (!$this->users->contains($user)) {
  46. $this->users[] = $user;
  47. }
  48. return $this;
  49. }
  50. public function removeUser(UserInterface $user): self
  51. {
  52. if ($this->users->contains($user)) {
  53. $this->users->removeElement($user);
  54. }
  55. return $this;
  56. }
  57. /**
  58. * @return Collection|GroupUserInterface[]
  59. */
  60. public function getGroupUsers(): Collection
  61. {
  62. return $this->groupUsers;
  63. }
  64. public function addGroupUser(GroupUserInterface $groupUser): self
  65. {
  66. if (!$this->groupUsers->contains($groupUser)) {
  67. $this->groupUsers[] = $groupUser;
  68. }
  69. return $this;
  70. }
  71. public function removeGroupUser(GroupUserInterface $groupUser): self
  72. {
  73. if ($this->groupUsers->contains($groupUser)) {
  74. $this->groupUsers->removeElement($groupUser);
  75. }
  76. return $this;
  77. }
  78. public function getDateStart(): ?\DateTimeInterface
  79. {
  80. return $this->dateStart;
  81. }
  82. public function setDateStart(?\DateTimeInterface $dateStart): self
  83. {
  84. $this->dateStart = $dateStart;
  85. return $this;
  86. }
  87. public function getDateEnd(): ?\DateTimeInterface
  88. {
  89. return $this->dateEnd;
  90. }
  91. public function setDateEnd(?\DateTimeInterface $dateEnd): self
  92. {
  93. $this->dateEnd = $dateEnd;
  94. return $this;
  95. }
  96. public function getPermanent(): ?bool
  97. {
  98. return $this->permanent;
  99. }
  100. public function setPermanent(bool $permanent): self
  101. {
  102. $this->permanent = $permanent;
  103. return $this;
  104. }
  105. }