Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

345 lines
9.5KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use App\Entity\Newsletter;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use FOS\UserBundle\Model\User as UserModelFOS;
  8. use Lc\ShopBundle\Context\MerchantInterface;
  9. /**
  10. * @ORM\MappedSuperclass()
  11. *
  12. */
  13. abstract class User extends UserModelFOS
  14. {
  15. /**
  16. * @ORM\Column(type="string", length=20, nullable=true)
  17. */
  18. protected $phone;
  19. /**
  20. * @ORM\Column(type="string", length=64, nullable=true)
  21. */
  22. protected $behaviorDisplayPrice;
  23. /**
  24. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  25. */
  26. protected $merchant;
  27. /**
  28. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="user", orphanRemoval=true)
  29. */
  30. protected $creditHistories;
  31. /**
  32. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\AddressInterface", mappedBy="user", cascade={"persist"})
  33. */
  34. protected $addresses;
  35. /**
  36. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="user")
  37. */
  38. protected $orders;
  39. /**
  40. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CartInterface", mappedBy="user")
  41. */
  42. protected $carts;
  43. /**
  44. * @ORM\Column(type="string", length=64, nullable=true)
  45. */
  46. protected $firstname;
  47. /**
  48. * @ORM\Column(type="string", length=64, nullable=true)
  49. */
  50. protected $lastname;
  51. /**
  52. * @ORM\Column(type="boolean", nullable=true)
  53. */
  54. protected $gender;
  55. /**
  56. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\NewsletterInterface", inversedBy="users")
  57. */
  58. protected $newsletters;
  59. /**
  60. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\GroupUserInterface", inversedBy="users")
  61. */
  62. protected $groupUsers;
  63. public function __construct()
  64. {
  65. parent::__construct();
  66. $this->creditHistories = new ArrayCollection();
  67. $this->addresses = new ArrayCollection();
  68. $this->orders = new ArrayCollection();
  69. $this->carts = new ArrayCollection();
  70. $this->newsletters = new ArrayCollection();
  71. $this->groupUsers = new ArrayCollection();
  72. }
  73. public function setEmail($email)
  74. {
  75. $this->setUsername($email);
  76. return parent::setEmail($email);
  77. }
  78. public function getPhone(): ?string
  79. {
  80. return $this->phone;
  81. }
  82. public function setPhone(?string $phone): self
  83. {
  84. $this->phone = $phone;
  85. return $this;
  86. }
  87. public function getBehaviorDisplayPrice(): ?string
  88. {
  89. return $this->behaviorDisplayPrice;
  90. }
  91. public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
  92. {
  93. $this->behaviorDisplayPrice = $behaviorDisplayPrice;
  94. return $this;
  95. }
  96. public function getMerchant(): ?MerchantInterface
  97. {
  98. return $this->merchant;
  99. }
  100. public function setMerchant(?MerchantInterface $merchant): self
  101. {
  102. $this->merchant = $merchant;
  103. return $this;
  104. }
  105. /**
  106. * @return Collection|CreditHistory[]
  107. */
  108. public function getCreditHistories(): Collection
  109. {
  110. return $this->creditHistories;
  111. }
  112. public function addCreditHistory(CreditHistory $creditHistory): self
  113. {
  114. if (!$this->creditHistories->contains($creditHistory)) {
  115. $this->creditHistories[] = $creditHistory;
  116. $creditHistory->setUser($this);
  117. }
  118. return $this;
  119. }
  120. public function removeCreditHistory(CreditHistory $creditHistory): self
  121. {
  122. if ($this->creditHistories->contains($creditHistory)) {
  123. $this->creditHistories->removeElement($creditHistory);
  124. // set the owning side to null (unless already changed)
  125. if ($creditHistory->getUser() === $this) {
  126. $creditHistory->setUser(null);
  127. }
  128. }
  129. return $this;
  130. }
  131. /**
  132. * @return Collection|Address[]
  133. */
  134. public function getAddresses(): Collection
  135. {
  136. return $this->addresses;
  137. }
  138. public function addAddress(Address $address): self
  139. {
  140. if (!$this->addresses->contains($address)) {
  141. $this->addresses[] = $address;
  142. $address->setUser($this);
  143. }
  144. return $this;
  145. }
  146. public function removeAddress(Address $address): self
  147. {
  148. if ($this->addresses->contains($address)) {
  149. $this->addresses->removeElement($address);
  150. // set the owning side to null (unless already changed)
  151. if ($address->getUser() === $this) {
  152. $address->setUser(null);
  153. }
  154. }
  155. return $this;
  156. }
  157. /**
  158. * @return Collection|ShopOrder[]
  159. */
  160. public function getOrders(): Collection
  161. {
  162. return $this->orders;
  163. }
  164. public function addOrder(OrderShop $order): self
  165. {
  166. if (!$this->orders->contains($order)) {
  167. $this->orders[] = $order;
  168. $order->setUser($this);
  169. }
  170. return $this;
  171. }
  172. public function removeOrder(OrderShop $order): self
  173. {
  174. if ($this->orders->contains($order)) {
  175. $this->orders->removeElement($order);
  176. // set the owning side to null (unless already changed)
  177. if ($order->getUser() === $this) {
  178. $order->setUser(null);
  179. }
  180. }
  181. return $this;
  182. }
  183. /**
  184. * @return Collection|Cart[]
  185. */
  186. public function getCarts(): Collection
  187. {
  188. return $this->carts;
  189. }
  190. public function addCart(Cart $cart): self
  191. {
  192. if (!$this->carts->contains($cart)) {
  193. $this->carts[] = $cart;
  194. $cart->setUser($this);
  195. }
  196. return $this;
  197. }
  198. public function removeCart(Cart $cart): self
  199. {
  200. if ($this->carts->contains($cart)) {
  201. $this->carts->removeElement($cart);
  202. // set the owning side to null (unless already changed)
  203. if ($cart->getUser() === $this) {
  204. $cart->setUser(null);
  205. }
  206. }
  207. return $this;
  208. }
  209. public function getFirstname(): ?string
  210. {
  211. return $this->firstname;
  212. }
  213. public function setFirstname(?string $firstname): self
  214. {
  215. $this->firstname = $firstname;
  216. return $this;
  217. }
  218. public function getLastname(): ?string
  219. {
  220. return $this->lastname;
  221. }
  222. public function setLastname(?string $lastname): self
  223. {
  224. $this->lastname = $lastname;
  225. return $this;
  226. }
  227. public function getGender(): ?bool
  228. {
  229. return $this->gender;
  230. }
  231. public function setGender(?bool $gender): self
  232. {
  233. $this->gender = $gender;
  234. return $this;
  235. }
  236. /**
  237. * @return Collection|Newsletter[]
  238. */
  239. public function getNewsletters(): Collection
  240. {
  241. return $this->newsletters;
  242. }
  243. public function addNewsletter(Newsletter $newsletter): self
  244. {
  245. if (!$this->newsletters->contains($newsletter)) {
  246. $this->newsletters[] = $newsletter;
  247. }
  248. return $this;
  249. }
  250. public function removeNewsletter(Newsletter $newsletter): self
  251. {
  252. if ($this->newsletters->contains($newsletter)) {
  253. $this->newsletters->removeElement($newsletter);
  254. }
  255. return $this;
  256. }
  257. /**
  258. * @return Collection|GroupUser[]
  259. */
  260. public function getGroupUsers(): Collection
  261. {
  262. return $this->groupUsers;
  263. }
  264. public function addGroupUser(GroupUser $groupUser): self
  265. {
  266. if (!$this->groupUsers->contains($groupUser)) {
  267. $this->groupUsers[] = $groupUser;
  268. $groupUser->addUser($this);
  269. }
  270. return $this;
  271. }
  272. public function removeGroupUser(GroupUser $groupUser): self
  273. {
  274. if ($this->groupUsers->contains($groupUser)) {
  275. $this->groupUsers->removeElement($groupUser);
  276. $groupUser->removeUser($this);
  277. }
  278. return $this;
  279. }
  280. }