src/Entity/Gos/PaymentSystem.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. /**
  8.  * @ORM\Table()
  9.  * @ORM\Entity(repositoryClass="App\Repository\PaymentSystemRepository")
  10.  * @ORM\HasLifecycleCallbacks
  11.  */
  12. class PaymentSystem
  13. {
  14.     /**
  15.      * @ORM\Column(type="integer")
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue(strategy="IDENTITY")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @var bool
  22.      *
  23.      * @ORM\Column(name="isActive", type="boolean", nullable=true)
  24.      */
  25.     private $isActive;
  26.     /**
  27.      * @ORM\Column(type="string", nullable=true)
  28.      */
  29.     private $name;
  30.     /**
  31.      * @Gedmo\Slug(fields={"name"})
  32.      * @ORM\Column(unique=true)
  33.      */
  34.     private $slug;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Notify", mappedBy="paymentSystem")
  37.      */
  38.     private $notify;
  39.     /**
  40.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\PortalSettings", mappedBy="paymentSystem")
  41.      */
  42.     private $portalSettings;
  43.     /**
  44.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductVariant", mappedBy="paymentSystem")
  45.      */
  46.     private $productVariant;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity="PaymentOptions", mappedBy="paymentSystem", fetch="EAGER")
  49.      */
  50.     private $paymentOptions;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity="Cart", mappedBy="paymentSystem")
  53.      */
  54.     private $cart;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity="Orders", mappedBy="paymentSystem")
  57.      */
  58.     private $orders;
  59.     /**
  60.      * @ORM\Column(type="datetime")
  61.      */
  62.     private $createdAt;
  63.     /**
  64.      * @ORM\Column(type="datetime", nullable=true)
  65.      */
  66.     private $updatedAt;
  67.     /** @ORM\PrePersist() */
  68.     public function prePersist()
  69.     {
  70.         $this->createdAt = new \DateTime();
  71.     }
  72.     /** @ORM\PreUpdate() */
  73.     public function preUpdate()
  74.     {
  75.         $this->updatedAt = new \DateTime();
  76.     }
  77.     public function __construct()
  78.     {
  79.         $this->notify = new ArrayCollection();
  80.         $this->portalSettings = new ArrayCollection();
  81.         $this->productVariant = new ArrayCollection();
  82.         $this->cart = new ArrayCollection();
  83.         $this->orders = new ArrayCollection();
  84.         $this->paymentOptions = new ArrayCollection();
  85.     }
  86.     public function __toString()
  87.     {
  88.         return (string)$this->name;
  89.     }
  90.     /**
  91.      * Get id
  92.      *
  93.      * @return integer
  94.      */
  95.     public function getId()
  96.     {
  97.         return $this->id;
  98.     }
  99.     /**
  100.      * Set isActive
  101.      *
  102.      * @param boolean $isActive
  103.      *
  104.      * @return PaymentSystem
  105.      */
  106.     public function setIsActive($isActive)
  107.     {
  108.         $this->isActive $isActive;
  109.         return $this;
  110.     }
  111.     /**
  112.      * Get isActive
  113.      *
  114.      * @return boolean
  115.      */
  116.     public function getIsActive()
  117.     {
  118.         return $this->isActive;
  119.     }
  120.     /**
  121.      * Set name
  122.      *
  123.      * @param string $name
  124.      *
  125.      * @return PaymentSystem
  126.      */
  127.     public function setName($name)
  128.     {
  129.         $this->name $name;
  130.         return $this;
  131.     }
  132.     /**
  133.      * Get name
  134.      *
  135.      * @return string
  136.      */
  137.     public function getName(Country $country null)
  138.     {
  139.         if ($country)
  140.         {
  141.             $paymentOptions $this->getPaymentOptions($country);
  142.             if ($paymentOptions && !empty($paymentOptions->getPaymentName()))
  143.             {
  144.                 return $paymentOptions->getPaymentName();
  145.             }
  146.         }
  147.         return $this->name;
  148.     }
  149.     /**
  150.      * Set slug
  151.      *
  152.      * @param string $slug
  153.      *
  154.      * @return PaymentSystem
  155.      */
  156.     public function setSlug($slug)
  157.     {
  158.         $this->slug $slug;
  159.         return $this;
  160.     }
  161.     /**
  162.      * Get slug
  163.      *
  164.      * @return string
  165.      */
  166.     public function getSlug()
  167.     {
  168.         return $this->slug;
  169.     }
  170.     /**
  171.      * Set createdAt
  172.      *
  173.      * @param \DateTime $createdAt
  174.      *
  175.      * @return PaymentSystem
  176.      */
  177.     public function setCreatedAt($createdAt)
  178.     {
  179.         $this->createdAt $createdAt;
  180.         return $this;
  181.     }
  182.     /**
  183.      * Get createdAt
  184.      *
  185.      * @return \DateTime
  186.      */
  187.     public function getCreatedAt()
  188.     {
  189.         return $this->createdAt;
  190.     }
  191.     /**
  192.      * Set updatedAt
  193.      *
  194.      * @param \DateTime $updatedAt
  195.      *
  196.      * @return PaymentSystem
  197.      */
  198.     public function setUpdatedAt($updatedAt)
  199.     {
  200.         $this->updatedAt $updatedAt;
  201.         return $this;
  202.     }
  203.     /**
  204.      * Get updatedAt
  205.      *
  206.      * @return \DateTime
  207.      */
  208.     public function getUpdatedAt()
  209.     {
  210.         return $this->updatedAt;
  211.     }
  212.     /**
  213.      * Add notify
  214.      *
  215.      * @param \App\Entity\Gos\Notify $notify
  216.      *
  217.      * @return PaymentSystem
  218.      */
  219.     public function addNotify(\App\Entity\Gos\Notify $notify)
  220.     {
  221.         $this->notify[] = $notify;
  222.         return $this;
  223.     }
  224.     /**
  225.      * Remove notify
  226.      *
  227.      * @param \App\Entity\Gos\Notify $notify
  228.      */
  229.     public function removeNotify(\App\Entity\Gos\Notify $notify)
  230.     {
  231.         $this->notify->removeElement($notify);
  232.     }
  233.     /**
  234.      * Get notify
  235.      *
  236.      * @return \Doctrine\Common\Collections\Collection
  237.      */
  238.     public function getNotify()
  239.     {
  240.         return $this->notify;
  241.     }
  242.     /**
  243.      * Add portalSetting
  244.      *
  245.      * @param \App\Entity\Gos\PortalSettings $portalSetting
  246.      *
  247.      * @return PaymentSystem
  248.      */
  249.     public function addPortalSetting(\App\Entity\Gos\PortalSettings $portalSetting)
  250.     {
  251.         $this->portalSettings[] = $portalSetting;
  252.         return $this;
  253.     }
  254.     /**
  255.      * Remove portalSetting
  256.      *
  257.      * @param \App\Entity\Gos\PortalSettings $portalSetting
  258.      */
  259.     public function removePortalSetting(\App\Entity\Gos\PortalSettings $portalSetting)
  260.     {
  261.         $this->portalSettings->removeElement($portalSetting);
  262.     }
  263.     /**
  264.      * Get portalSettings
  265.      *
  266.      * @return \Doctrine\Common\Collections\Collection
  267.      */
  268.     public function getPortalSettings()
  269.     {
  270.         return $this->portalSettings;
  271.     }
  272.     /**
  273.      * @return Collection|ProductVariant[]
  274.      */
  275.     public function getProductVariant(): Collection
  276.     {
  277.         return $this->productVariant;
  278.     }
  279.     public function addProductVariant(ProductVariant $productVariant): self
  280.     {
  281.         if (!$this->productVariant->contains($productVariant)) {
  282.             $this->productVariant[] = $productVariant;
  283.             $productVariant->addPaymentSystem($this);
  284.         }
  285.         return $this;
  286.     }
  287.     public function removeProductVariant(ProductVariant $productVariant): self
  288.     {
  289.         if ($this->productVariant->contains($productVariant)) {
  290.             $this->productVariant->removeElement($productVariant);
  291.             $productVariant->removePaymentSystem($this);
  292.         }
  293.         return $this;
  294.     }
  295.     public function getIcon()
  296.     {
  297.         if (!is_null($this->getPaymentOptions()) && !($this->getPaymentOptions() instanceof Collection))
  298.             return $this->getPaymentOptions()->getIcon();
  299.         return null;
  300.     }
  301.     /**
  302.      * @return Collection|Cart[]
  303.      */
  304.     public function getCart(): Collection
  305.     {
  306.         return $this->cart;
  307.     }
  308.     public function addCart(Cart $cart): self
  309.     {
  310.         if (!$this->cart->contains($cart)) {
  311.             $this->cart[] = $cart;
  312.             $cart->setPaymentSystem($this);
  313.         }
  314.         return $this;
  315.     }
  316.     public function removeCart(Cart $cart): self
  317.     {
  318.         if ($this->cart->contains($cart)) {
  319.             $this->cart->removeElement($cart);
  320.             // set the owning side to null (unless already changed)
  321.             if ($cart->getPaymentSystem() === $this) {
  322.                 $cart->setPaymentSystem(null);
  323.             }
  324.         }
  325.         return $this;
  326.     }
  327.     /**
  328.      * @return Collection|Orders[]
  329.      */
  330.     public function getOrders(): Collection
  331.     {
  332.         return $this->orders;
  333.     }
  334.     public function addOrder(Orders $order): self
  335.     {
  336.         if (!$this->orders->contains($order)) {
  337.             $this->orders[] = $order;
  338.             $order->setPaymentSystem($this);
  339.         }
  340.         return $this;
  341.     }
  342.     public function removeOrder(Orders $order): self
  343.     {
  344.         if ($this->orders->contains($order)) {
  345.             $this->orders->removeElement($order);
  346.             // set the owning side to null (unless already changed)
  347.             if ($order->getPaymentSystem() === $this) {
  348.                 $order->setPaymentSystem(null);
  349.             }
  350.         }
  351.         return $this;
  352.     }
  353.     public function getPaymentOptions(Country $country null)
  354.     {
  355.         if ($country)
  356.         {
  357.             foreach ($this->paymentOptions as $paymentOption)
  358.             {
  359.                 if ($paymentOption->getCountry()->contains($country))
  360.                 {
  361.                     return $paymentOption;
  362.                 }
  363.             }
  364.         }
  365.         return null;
  366.     }
  367.     public function addPaymentOption(PaymentOptions $paymentOption): self
  368.     {
  369.         if (!$this->paymentOptions->contains($paymentOption)) {
  370.             $this->paymentOptions[] = $paymentOption;
  371.             $paymentOption->setPaymentSystem($this);
  372.         }
  373.         return $this;
  374.     }
  375.     public function removePaymentOption(PaymentOptions $paymentOption): self
  376.     {
  377.         if ($this->paymentOptions->contains($paymentOption)) {
  378.             $this->paymentOptions->removeElement($paymentOption);
  379.             // set the owning side to null (unless already changed)
  380.             if ($paymentOption->getPaymentSystem() === $this) {
  381.                 $paymentOption->setPaymentSystem(null);
  382.             }
  383.         }
  384.         return $this;
  385.     }
  386.     public function getPosition(Country $country nullPortalSettings $portalSettings null): ?int
  387.     {
  388.         if ($portalSettings && $portalSettings->getDefaultPaymentSystem() &&
  389.             $portalSettings->getDefaultPaymentSystem() === $this) return -1;
  390.         if ($country)
  391.         {
  392.             $paymentOptions $this->getPaymentOptions($country);
  393.             if ($paymentOptions)
  394.             {
  395.                 return $paymentOptions->getPosition();
  396.             }
  397.         }
  398.         return 0;
  399.     }
  400. }