Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

378 lines
11KB

  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. /**
  64. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
  65. */
  66. protected $favoriteProductFamilies;
  67. public function __construct()
  68. {
  69. parent::__construct();
  70. $this->creditHistories = new ArrayCollection();
  71. $this->addresses = new ArrayCollection();
  72. $this->orders = new ArrayCollection();
  73. $this->carts = new ArrayCollection();
  74. $this->groupUsers = new ArrayCollection();
  75. $this->newsletters = new ArrayCollection();
  76. $this->favoriteProductFamilies = new ArrayCollection();
  77. }
  78. public function setEmail($email)
  79. {
  80. $this->setUsername($email);
  81. return parent::setEmail($email);
  82. }
  83. public function getPhone(): ?string
  84. {
  85. return $this->phone;
  86. }
  87. public function setPhone(?string $phone): self
  88. {
  89. $this->phone = $phone;
  90. return $this;
  91. }
  92. public function getBehaviorDisplayPrice(): ?string
  93. {
  94. return $this->behaviorDisplayPrice;
  95. }
  96. public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
  97. {
  98. $this->behaviorDisplayPrice = $behaviorDisplayPrice;
  99. return $this;
  100. }
  101. public function getMerchant(): ?MerchantInterface
  102. {
  103. return $this->merchant;
  104. }
  105. public function setMerchant(?MerchantInterface $merchant): self
  106. {
  107. $this->merchant = $merchant;
  108. return $this;
  109. }
  110. /**
  111. * @return Collection|CreditHistory[]
  112. */
  113. public function getCreditHistories(): Collection
  114. {
  115. return $this->creditHistories;
  116. }
  117. public function addCreditHistory(CreditHistory $creditHistory): self
  118. {
  119. if (!$this->creditHistories->contains($creditHistory)) {
  120. $this->creditHistories[] = $creditHistory;
  121. $creditHistory->setUser($this);
  122. }
  123. return $this;
  124. }
  125. public function removeCreditHistory(CreditHistory $creditHistory): self
  126. {
  127. if ($this->creditHistories->contains($creditHistory)) {
  128. $this->creditHistories->removeElement($creditHistory);
  129. // set the owning side to null (unless already changed)
  130. if ($creditHistory->getUser() === $this) {
  131. $creditHistory->setUser(null);
  132. }
  133. }
  134. return $this;
  135. }
  136. /**
  137. * @return Collection|Address[]
  138. */
  139. public function getAddresses(): Collection
  140. {
  141. return $this->addresses;
  142. }
  143. public function addAddress(Address $address): self
  144. {
  145. if (!$this->addresses->contains($address)) {
  146. $this->addresses[] = $address;
  147. $address->setUser($this);
  148. }
  149. return $this;
  150. }
  151. public function removeAddress(Address $address): self
  152. {
  153. if ($this->addresses->contains($address)) {
  154. $this->addresses->removeElement($address);
  155. // set the owning side to null (unless already changed)
  156. if ($address->getUser() === $this) {
  157. $address->setUser(null);
  158. }
  159. }
  160. return $this;
  161. }
  162. /**
  163. * @return Collection|ShopOrder[]
  164. */
  165. public function getOrders(): Collection
  166. {
  167. return $this->orders;
  168. }
  169. public function addOrder(OrderShop $order): self
  170. {
  171. if (!$this->orders->contains($order)) {
  172. $this->orders[] = $order;
  173. $order->setUser($this);
  174. }
  175. return $this;
  176. }
  177. public function removeOrder(OrderShop $order): self
  178. {
  179. if ($this->orders->contains($order)) {
  180. $this->orders->removeElement($order);
  181. // set the owning side to null (unless already changed)
  182. if ($order->getUser() === $this) {
  183. $order->setUser(null);
  184. }
  185. }
  186. return $this;
  187. }
  188. /**
  189. * @return Collection|Cart[]
  190. */
  191. public function getCarts(): Collection
  192. {
  193. return $this->carts;
  194. }
  195. public function addCart(Cart $cart): self
  196. {
  197. if (!$this->carts->contains($cart)) {
  198. $this->carts[] = $cart;
  199. $cart->setUser($this);
  200. }
  201. return $this;
  202. }
  203. public function removeCart(Cart $cart): self
  204. {
  205. if ($this->carts->contains($cart)) {
  206. $this->carts->removeElement($cart);
  207. // set the owning side to null (unless already changed)
  208. if ($cart->getUser() === $this) {
  209. $cart->setUser(null);
  210. }
  211. }
  212. return $this;
  213. }
  214. public function getFirstname(): ?string
  215. {
  216. return $this->firstname;
  217. }
  218. public function setFirstname(?string $firstname): self
  219. {
  220. $this->firstname = $firstname;
  221. return $this;
  222. }
  223. public function getLastname(): ?string
  224. {
  225. return $this->lastname;
  226. }
  227. public function setLastname(?string $lastname): self
  228. {
  229. $this->lastname = $lastname;
  230. return $this;
  231. }
  232. public function getGender(): ?bool
  233. {
  234. return $this->gender;
  235. }
  236. public function setGender(?bool $gender): self
  237. {
  238. $this->gender = $gender;
  239. return $this;
  240. }
  241. /**
  242. * @return Collection|Newsletter[]
  243. */
  244. public function getNewsletters(): Collection
  245. {
  246. return $this->newsletters;
  247. }
  248. public function addNewsletter(Newsletter $newsletter): self
  249. {
  250. if (!$this->newsletters->contains($newsletter)) {
  251. $this->newsletters[] = $newsletter;
  252. }
  253. return $this;
  254. }
  255. public function removeNewsletter(Newsletter $newsletter): self
  256. {
  257. if ($this->newsletters->contains($newsletter)) {
  258. $this->newsletters->removeElement($newsletter);
  259. }
  260. return $this;
  261. }
  262. /**
  263. * @return Collection|GroupUser[]
  264. */
  265. public function getGroupUsers(): Collection
  266. {
  267. return $this->groupUsers;
  268. }
  269. public function addGroupUser(GroupUser $groupUser): self
  270. {
  271. if (!$this->groupUsers->contains($groupUser)) {
  272. $this->groupUsers[] = $groupUser;
  273. $groupUser->addUser($this);
  274. }
  275. return $this;
  276. }
  277. public function removeGroupUser(GroupUser $groupUser): self
  278. {
  279. if ($this->groupUsers->contains($groupUser)) {
  280. $this->groupUsers->removeElement($groupUser);
  281. $groupUser->removeUser($this);
  282. }
  283. return $this;
  284. }
  285. /**
  286. * @return Collection|ProductFamily[]
  287. */
  288. public function getFavoriteProductFamilies(): Collection
  289. {
  290. return $this->favoriteProductFamilies;
  291. }
  292. public function addFavoriteProductFamily(ProductFamily $favoriteProductFamily): self
  293. {
  294. if (!$this->favoriteProductFamilies->contains($favoriteProductFamily)) {
  295. $this->favoriteProductFamilies[] = $favoriteProductFamily;
  296. }
  297. return $this;
  298. }
  299. public function removeFavoriteProductFamily(ProductFamily $favoriteProductFamily): self
  300. {
  301. if ($this->favoriteProductFamilies->contains($favoriteProductFamily)) {
  302. $this->favoriteProductFamilies->removeElement($favoriteProductFamily);
  303. }
  304. return $this;
  305. }
  306. }