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.

416 lines
12KB

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