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.

160 lines
3.5KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Reduction;
  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\Doctrine\Extension\FilterSectionInterface;
  8. use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface;
  9. use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait;
  10. use Lc\CaracoleBundle\Model\Config\UnitModel;
  11. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  12. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  13. use Lc\SovBundle\Doctrine\Extension\StatusInterface;
  14. use Lc\SovBundle\Doctrine\Extension\StatusTrait;
  15. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  16. use Lc\SovBundle\Model\User\UserInterface;
  17. /**
  18. * @ORM\MappedSuperclass()
  19. */
  20. abstract class ReductionCreditModel extends AbstractLightEntity implements ReductionInterface, FilterSectionInterface,
  21. StatusInterface
  22. {
  23. const TYPE_CREDIT = 'credit';
  24. const TYPE_GIFT = 'gift';
  25. use ReductionTrait;
  26. use StatusTrait;
  27. /**
  28. * @ORM\Column(type="string", length=255)
  29. */
  30. protected $title;
  31. /**
  32. * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="reductionCredits")
  33. */
  34. protected $users;
  35. /**
  36. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
  37. * @ORM\JoinColumn(nullable=false)
  38. */
  39. protected $section;
  40. /**
  41. * @ORM\Column(type="string", length=255)
  42. */
  43. protected $type;
  44. /**
  45. * @ORM\Column(type="boolean", nullable=true)
  46. */
  47. protected $sended;
  48. /**
  49. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
  50. */
  51. protected $owner;
  52. public function __construct()
  53. {
  54. $this->users = new ArrayCollection();
  55. $this->unit = UnitModel::UNIT_AMOUNT;
  56. }
  57. public function __toString()
  58. {
  59. return $this->title;
  60. }
  61. public function getTitle(): ?string
  62. {
  63. return $this->title;
  64. }
  65. public function setTitle(string $title): self
  66. {
  67. $this->title = $title;
  68. return $this;
  69. }
  70. public function getSection(): SectionInterface
  71. {
  72. return $this->section;
  73. }
  74. public function setSection(SectionInterface $section): self
  75. {
  76. $this->section = $section;
  77. return $this;
  78. }
  79. public function getType(): ?string
  80. {
  81. return $this->type;
  82. }
  83. public function setType(string $type): self
  84. {
  85. $this->type = $type;
  86. return $this;
  87. }
  88. /**
  89. * @return Collection|UserInterface[]
  90. */
  91. public function getUsers(): Collection
  92. {
  93. return $this->users;
  94. }
  95. public function addUser(UserInterface $user): self
  96. {
  97. if (!$this->users->contains($user)) {
  98. $this->users[] = $user;
  99. }
  100. return $this;
  101. }
  102. public function removeUser(UserInterface $user): self
  103. {
  104. if ($this->users->contains($user)) {
  105. $this->users->removeElement($user);
  106. }
  107. return $this;
  108. }
  109. public function getSended(): ?bool
  110. {
  111. return $this->sended;
  112. }
  113. public function setSended(?bool $sended): self
  114. {
  115. $this->sended = $sended;
  116. return $this;
  117. }
  118. public function getOwner(): ?UserInterface
  119. {
  120. return $this->owner;
  121. }
  122. public function setOwner(?UserInterface $owner): self
  123. {
  124. $this->owner = $owner;
  125. return $this;
  126. }
  127. }