|
- <?php
-
- namespace Lc\CaracoleBundle\Model\User;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\CaracoleBundle\Model\Address\AddressInterface;
- use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
- use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
- use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
- use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
- use Lc\SovBundle\Model\User\UserModel as SovUserModel;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
-
- /**
- * @ORM\MappedSuperclass()
- *
- */
- abstract class UserModel extends SovUserModel
- {
- /**
- * @ORM\Column(type="string", length=64, nullable=true)
- */
- protected $behaviorDisplayPrice;
-
- /**
- * @ORM\Column(type="boolean", nullable=true)
- */
- protected $isSaleAlwaysOpen;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
- */
- protected $favoriteMerchant;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", mappedBy="user", cascade={"persist", "remove"})
- */
- protected $addresses;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="user")
- */
- protected $orderShops;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", inversedBy="users")
- */
- protected $newsletters;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface")
- */
- protected $favoriteProductFamilies;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserPointSaleInterface", mappedBy="user", orphanRemoval=true)
- */
- protected $userPointSales;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserMerchantInterface", mappedBy="user", orphanRemoval=true)
- */
- protected $userMerchants;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface", mappedBy="users")
- */
- protected $reductionCredits;
-
- public function __construct()
- {
- parent::__construct();
- $this->addresses = new ArrayCollection();
- $this->orderShops = new ArrayCollection();
- $this->groupUsers = new ArrayCollection();
- $this->newsletters = new ArrayCollection();
- $this->favoriteProductFamilies = new ArrayCollection();
- $this->userPointSales = new ArrayCollection();
- $this->userMerchants = new ArrayCollection();
- $this->reductionCredits = new ArrayCollection();
-
- }
-
- public function getBehaviorDisplayPrice(): ?string
- {
- return $this->behaviorDisplayPrice;
- }
-
- public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
- {
- $this->behaviorDisplayPrice = $behaviorDisplayPrice;
-
- return $this;
- }
-
- public function getIsSaleAlwaysOpen(): ?bool
- {
- return $this->isSaleAlwaysOpen;
- }
-
- public function setIsSaleAlwaysOpen(?bool $isSaleAlwaysOpen): self
- {
- $this->isSaleAlwaysOpen = $isSaleAlwaysOpen;
-
- return $this;
- }
- public function getFavoriteMerchant(): ?MerchantInterface
- {
- return $this->favoriteMerchant;
- }
-
- public function setFavoriteMerchant(?MerchantInterface $merchant): self
- {
- $this->favoriteMerchant = $merchant;
-
- return $this;
- }
-
- /**
- * @return Collection|AddressInterface[]
- */
- public function getAddresses($status = null): Collection
- {
- if ($status) {
- $addressToReturn = new ArrayCollection();
- foreach ($this->addresses as $address) {
- if ($address->getStatus() == $status) {
- $addressToReturn[] = $address;
- }
- }
- return $addressToReturn;
- } else {
- return $this->addresses;
- }
- }
-
- public function addAddress(AddressInterface $address): self
- {
- if (!$this->addresses->contains($address)) {
- $this->addresses[] = $address;
- $address->setUser($this);
- }
-
- return $this;
- }
-
- public function removeAddress(AddressInterface $address): self
- {
- if ($this->addresses->contains($address)) {
- $this->addresses->removeElement($address);
- // set the owning side to null (unless already changed)
- if ($address->getUser() === $this) {
- $address->setUser(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|OrderShopInterface[]
- */
- public function getOrderShops(): Collection
- {
- return $this->orderShops;
- }
-
- public function addOrderShop(OrderShopInterface $orderShop): self
- {
- if (!$this->orderShops->contains($orderShop)) {
- $this->orderShops[] = $orderShop;
- $orderShop->setUser($this);
- }
-
- return $this;
- }
-
- public function removeOrderShop(OrderShopInterface $orderShop): self
- {
- if ($this->orderShops->contains($orderShop)) {
- $this->orderShops->removeElement($orderShop);
- // set the owning side to null (unless already changed)
- if ($orderShop->getUser() === $this) {
- $orderShop->setUser(null);
- }
- }
-
- return $this;
- }
-
-
- /**
- * @return Collection|NewsletterInterface[]
- */
- public function getNewsletters(): Collection
- {
- return $this->newsletters;
- }
-
- public function addNewsletter(NewsletterInterface $newsletter): self
- {
- if (!$this->newsletters->contains($newsletter)) {
- $this->newsletters[] = $newsletter;
- }
-
- return $this;
- }
-
- public function removeNewsletter(NewsletterInterface $newsletter): self
- {
- if ($this->newsletters->contains($newsletter)) {
- $this->newsletters->removeElement($newsletter);
- }
-
- return $this;
- }
-
-
- /**
- * @return Collection|ProductFamilyInterface[]
- */
- public function getFavoriteProductFamilies(): Collection
- {
- return $this->favoriteProductFamilies;
- }
-
- public function addFavoriteProductFamily(ProductFamilyInterface $favoriteProductFamily): self
- {
- if (!$this->favoriteProductFamilies->contains($favoriteProductFamily)) {
- $this->favoriteProductFamilies[] = $favoriteProductFamily;
- }
-
- return $this;
- }
-
- public function removeFavoriteProductFamily(ProductFamilyInterface $favoriteProductFamily): self
- {
- if ($this->favoriteProductFamilies->contains($favoriteProductFamily)) {
- $this->favoriteProductFamilies->removeElement($favoriteProductFamily);
- }
-
- return $this;
- }
-
- /**
- * @return Collection|UserPointSaleInterface[]
- */
- public function getUserPointSales(): Collection
- {
- return $this->userPointSales;
- }
-
- public function addUserPointSale(UserPointSaleInterface $userPointSale): self
- {
- if (!$this->userPointSales->contains($userPointSale)) {
- $this->userPointSales[] = $userPointSale;
- $userPointSale->setUser($this);
- }
-
- return $this;
- }
-
- public function removeUserPointSale(UserPointSaleInterface $userPointSale): self
- {
- if ($this->userPointSales->contains($userPointSale)) {
- $this->userPointSales->removeElement($userPointSale);
- // set the owning side to null (unless already changed)
- if ($userPointSale->getUser() === $this) {
- $userPointSale->setUser(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|ReductionCreditInterface[]
- */
- public function getReductionCredits(): Collection
- {
- return $this->reductionCredits;
- }
-
- public function addReductionCredit(ReductionCreditInterface $reductionCredit): self
- {
- if (!$this->reductionCredits->contains($reductionCredit)) {
- $this->reductionCredits[] = $reductionCredit;
- $reductionCredit->addUser($this);
- }
-
- return $this;
- }
-
- public function removeReductionCredit(ReductionCreditInterface $reductionCredit): self
- {
- if ($this->reductionCredits->contains($reductionCredit)) {
- $this->reductionCredits->removeElement($reductionCredit);
- $reductionCredit->removeUser($this);
- }
-
- return $this;
- }
-
- }
|