Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

428 Zeilen
12KB

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