src/Flexy/ShopBundle/Entity/Payment/PaymentMethod.php line 25

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Payment;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use App\Flexy\ShopBundle\Entity\Accounting\Invoice;
  7. use App\Flexy\ShopBundle\Entity\Order\Order;
  8. use App\Flexy\ShopBundle\Entity\Product\Product;
  9. use App\Flexy\ShopBundle\Entity\Shipping\Country;
  10. use App\Flexy\ShopBundle\Repository\Payment\PaymentMethodRepository;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. #[ApiResource(
  16.     normalizationContext: ['groups' => ['read']],
  17.     denormalizationContext: ['groups' => ['write']],
  18. )]
  19. #[ApiFilter(SearchFilter::class, properties: ['type' => 'exact'])]
  20. #[ORM\Entity(repositoryClassPaymentMethodRepository::class)]
  21. #[ORM\Cache(usage:"NONSTRICT_READ_WRITE",region:"append_depend")]
  22. class PaymentMethod implements \Stringable
  23. {
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue]
  26.     #[ORM\Column(type'integer')]
  27.     #[Groups(["read"])]
  28.     private $id;
  29.     #[Groups(["write","read"])]
  30.     #[ORM\Column(type'string'length255)]
  31.     private ?string $name null;
  32.     #[ORM\Column(type'string'length255nullabletrue)]
  33.     private ?string $image null;
  34.     #[Groups(["write","read"])]
  35.     #[ORM\Column(type'text'nullabletrue)]
  36.     private ?string $description null;
  37.     #[Groups(["write","read"])]
  38.     #[ORM\Column(type'string'length255)]
  39.     private ?string $code null;
  40.     #[Groups(["write","read"])]
  41.     #[ORM\Column(type'boolean'nullabletrue)]
  42.     private ?bool $isEnabled null;
  43.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  44.     private ?\DateTimeImmutable $createdAt null;
  45.     #[ORM\Column(type'integer'nullabletrue)]
  46.     private ?int $position null;
  47.     #[ORM\OneToMany(targetEntityPayment::class, mappedBy'paymentMethod')]
  48.     private \Doctrine\Common\Collections\Collection|array $payments;
  49.     #[ORM\OneToMany(targetEntityOrder::class, mappedBy'paymentMethod'cascade: ['persist'])]
  50.     #[ORM\JoinColumn(nullabletrueonDelete'CASCADE')]
  51.     private \Doctrine\Common\Collections\Collection|array $orders;
  52.     #[ORM\OneToMany(mappedBy'paymentMethod'targetEntityInvoice::class)]
  53.     private Collection $invoices;
  54.     #[ORM\Column(length255nullabletrue)]
  55.     private ?string $type null;
  56.     #[ORM\Column(length255nullabletrue)]
  57.     private ?string $secretKey null;
  58.     #[ORM\Column(length255nullabletrue)]
  59.     private ?string $publicKey null;
  60.     #[ORM\Column(nullabletrue)]
  61.     private array $displayOn = [];
  62.     #[ORM\Column(length255nullabletrue)]
  63.     private ?string $baseURL null;
  64.     #[ORM\Column(length255nullabletrue)]
  65.     private ?string $returnURL null;
  66.     #[ORM\Column(length255nullabletrue)]
  67.     private ?string $cancelURL null;
  68.     #[ORM\Column(length255nullabletrue)]
  69.     private ?string $publicKeySandBox null;
  70.     #[ORM\Column(length255nullabletrue)]
  71.     private ?string $secretKeySandBox null;
  72.     #[ORM\Column(length255nullabletrue)]
  73.     private ?string $baseURLSandBox null;
  74.     #[ORM\Column(nullabletrue)]
  75.     private ?bool $isSandBoxEnabled null;
  76.     #[ORM\ManyToMany(targetEntityCountry::class, inversedBy'paymentMethods')]
  77.     private Collection $includedCountries;
  78.     #[ORM\ManyToMany(targetEntityProduct::class, mappedBy'includedPaymentMethods')]
  79.     private Collection $products;
  80.     public function __construct()
  81.     {
  82.         $this->payments = new ArrayCollection();
  83.         $this->orders = new ArrayCollection();
  84.         $this->invoices = new ArrayCollection();
  85.         $this->includedCountries = new ArrayCollection();
  86.         $this->products = new ArrayCollection();
  87.     }
  88.     public function __toString(): string
  89.     {
  90.         return (string)$this->name;
  91.     }
  92.     public function getId(): ?int
  93.     {
  94.         return $this->id;
  95.     }
  96.     public function getName(): ?string
  97.     {
  98.         return $this->name;
  99.     }
  100.     public function setName(string $name): self
  101.     {
  102.         $this->name $name;
  103.         return $this;
  104.     }
  105.     public function getImage(): ?string
  106.     {
  107.         return $this->image;
  108.     }
  109.     public function setImage(?string $image): self
  110.     {
  111.         $this->image $image;
  112.         return $this;
  113.     }
  114.     public function getDescription(): ?string
  115.     {
  116.         return $this->description;
  117.     }
  118.     public function setDescription(?string $description): self
  119.     {
  120.         $this->description $description;
  121.         return $this;
  122.     }
  123.     public function getCode(): ?string
  124.     {
  125.         return $this->code;
  126.     }
  127.     public function setCode(string $code): self
  128.     {
  129.         $this->code $code;
  130.         return $this;
  131.     }
  132.     public function getIsEnabled(): ?bool
  133.     {
  134.         return $this->isEnabled;
  135.     }
  136.     public function setIsEnabled(?bool $isEnabled): self
  137.     {
  138.         $this->isEnabled $isEnabled;
  139.         return $this;
  140.     }
  141.     public function getCreatedAt(): ?\DateTimeImmutable
  142.     {
  143.         return $this->createdAt;
  144.     }
  145.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  146.     {
  147.         $this->createdAt $createdAt;
  148.         return $this;
  149.     }
  150.     public function getPosition(): ?int
  151.     {
  152.         return $this->position;
  153.     }
  154.     public function setPosition(?int $position): self
  155.     {
  156.         $this->position $position;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection|Payment[]
  161.      */
  162.     public function getPayments(): Collection
  163.     {
  164.         return $this->payments;
  165.     }
  166.     public function addPayment(Payment $payment): self
  167.     {
  168.         if (!$this->payments->contains($payment)) {
  169.             $this->payments[] = $payment;
  170.             $payment->setPaymentMethod($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removePayment(Payment $payment): self
  175.     {
  176.         if ($this->payments->removeElement($payment)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($payment->getPaymentMethod() === $this) {
  179.                 $payment->setPaymentMethod(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return Collection<int, Order>
  186.      */
  187.     public function getOrders(): Collection
  188.     {
  189.         return $this->orders;
  190.     }
  191.     public function addOrder(Order $order): self
  192.     {
  193.         if (!$this->orders->contains($order)) {
  194.             $this->orders[] = $order;
  195.             $order->setPaymentMethod($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeOrder(Order $order): self
  200.     {
  201.         if ($this->orders->removeElement($order)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($order->getPaymentMethod() === $this) {
  204.                 $order->setPaymentMethod(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection<int, Invoice>
  211.      */
  212.     public function getInvoices(): Collection
  213.     {
  214.         return $this->invoices;
  215.     }
  216.     public function addInvoice(Invoice $invoice): self
  217.     {
  218.         if (!$this->invoices->contains($invoice)) {
  219.             $this->invoices->add($invoice);
  220.             $invoice->setPaymentMethod($this);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removeInvoice(Invoice $invoice): self
  225.     {
  226.         if ($this->invoices->removeElement($invoice)) {
  227.             // set the owning side to null (unless already changed)
  228.             if ($invoice->getPaymentMethod() === $this) {
  229.                 $invoice->setPaymentMethod(null);
  230.             }
  231.         }
  232.         return $this;
  233.     }
  234.     public function getType(): ?string
  235.     {
  236.         return $this->type;
  237.     }
  238.     public function setType(?string $type): self
  239.     {
  240.         $this->type $type;
  241.         return $this;
  242.     }
  243.     public function getSecretKey(): ?string
  244.     {
  245.         return $this->secretKey;
  246.     }
  247.     public function setSecretKey(?string $secretKey): self
  248.     {
  249.         $this->secretKey $secretKey;
  250.         return $this;
  251.     }
  252.     public function getPublicKey(): ?string
  253.     {
  254.         return $this->publicKey;
  255.     }
  256.     public function setPublicKey(?string $publicKey): self
  257.     {
  258.         $this->publicKey $publicKey;
  259.         return $this;
  260.     }
  261.     public function getDisplayOn(): array
  262.     {
  263.         return $this->displayOn;
  264.     }
  265.     public function setDisplayOn(?array $displayOn): self
  266.     {
  267.         $this->displayOn $displayOn;
  268.         return $this;
  269.     }
  270.     public function getBaseURL(): ?string
  271.     {
  272.         return $this->baseURL;
  273.     }
  274.     public function setBaseURL(?string $baseURL): static
  275.     {
  276.         $this->baseURL $baseURL;
  277.         return $this;
  278.     }
  279.     public function getReturnURL(): ?string
  280.     {
  281.         return $this->returnURL;
  282.     }
  283.     public function setReturnURL(?string $returnURL): static
  284.     {
  285.         $this->returnURL $returnURL;
  286.         return $this;
  287.     }
  288.     public function getCancelURL(): ?string
  289.     {
  290.         return $this->cancelURL;
  291.     }
  292.     public function setCancelURL(?string $cancelURL): static
  293.     {
  294.         $this->cancelURL $cancelURL;
  295.         return $this;
  296.     }
  297.     public function getPublicKeySandBox(): ?string
  298.     {
  299.         return $this->publicKeySandBox;
  300.     }
  301.     public function setPublicKeySandBox(?string $publicKeySandBox): static
  302.     {
  303.         $this->publicKeySandBox $publicKeySandBox;
  304.         return $this;
  305.     }
  306.     public function getSecretKeySandBox(): ?string
  307.     {
  308.         return $this->secretKeySandBox;
  309.     }
  310.     public function setSecretKeySandBox(?string $secretKeySandBox): static
  311.     {
  312.         $this->secretKeySandBox $secretKeySandBox;
  313.         return $this;
  314.     }
  315.     public function getBaseURLSandBox(): ?string
  316.     {
  317.         return $this->baseURLSandBox;
  318.     }
  319.     public function setBaseURLSandBox(?string $baseURLSandBox): static
  320.     {
  321.         $this->baseURLSandBox $baseURLSandBox;
  322.         return $this;
  323.     }
  324.     public function isSandBoxEnabled(): ?bool
  325.     {
  326.         return $this->isSandBoxEnabled;
  327.     }
  328.     public function setIsSandBoxEnabled(?bool $isSandBoxEnabled): static
  329.     {
  330.         $this->isSandBoxEnabled $isSandBoxEnabled;
  331.         return $this;
  332.     }
  333.     /**
  334.      * @return Collection<int, Country>
  335.      */
  336.     public function getIncludedCountries(): Collection
  337.     {
  338.         return $this->includedCountries;
  339.     }
  340.     public function addIncludedCountry(Country $includedCountry): static
  341.     {
  342.         if (!$this->includedCountries->contains($includedCountry)) {
  343.             $this->includedCountries->add($includedCountry);
  344.         }
  345.         return $this;
  346.     }
  347.     public function removeIncludedCountry(Country $includedCountry): static
  348.     {
  349.         $this->includedCountries->removeElement($includedCountry);
  350.         return $this;
  351.     }
  352.     /**
  353.      * @return Collection<int, Product>
  354.      */
  355.     public function getProducts(): Collection
  356.     {
  357.         return $this->products;
  358.     }
  359.     public function addProduct(Product $product): static
  360.     {
  361.         if (!$this->products->contains($product)) {
  362.             $this->products->add($product);
  363.             $product->addIncludedPaymentMethod($this);
  364.         }
  365.         return $this;
  366.     }
  367.     public function removeProduct(Product $product): static
  368.     {
  369.         if ($this->products->removeElement($product)) {
  370.             $product->removeIncludedPaymentMethod($this);
  371.         }
  372.         return $this;
  373.     }
  374. }