src/Flexy/ShopBundle/Entity/Payment/PaymentMethod.php line 25
<?php
namespace App\Flexy\ShopBundle\Entity\Payment;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use App\Flexy\ShopBundle\Entity\Accounting\Invoice;
use App\Flexy\ShopBundle\Entity\Order\Order;
use App\Flexy\ShopBundle\Entity\Product\Product;
use App\Flexy\ShopBundle\Entity\Shipping\Country;
use App\Flexy\ShopBundle\Repository\Payment\PaymentMethodRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
)]
#[ApiFilter(SearchFilter::class, properties: ['type' => 'exact'])]
#[ORM\Entity(repositoryClass: PaymentMethodRepository::class)]
#[ORM\Cache(usage:"NONSTRICT_READ_WRITE",region:"append_depend")]
class PaymentMethod implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(["read"])]
private $id;
#[Groups(["write","read"])]
#[ORM\Column(type: 'string', length: 255)]
private ?string $name = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $image = null;
#[Groups(["write","read"])]
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
#[Groups(["write","read"])]
#[ORM\Column(type: 'string', length: 255)]
private ?string $code = null;
#[Groups(["write","read"])]
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isEnabled = null;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $position = null;
#[ORM\OneToMany(targetEntity: Payment::class, mappedBy: 'paymentMethod')]
private \Doctrine\Common\Collections\Collection|array $payments;
#[ORM\OneToMany(targetEntity: Order::class, mappedBy: 'paymentMethod', cascade: ['persist'])]
#[ORM\JoinColumn(nullable: true, onDelete: 'CASCADE')]
private \Doctrine\Common\Collections\Collection|array $orders;
#[ORM\OneToMany(mappedBy: 'paymentMethod', targetEntity: Invoice::class)]
private Collection $invoices;
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $secretKey = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $publicKey = null;
#[ORM\Column(nullable: true)]
private array $displayOn = [];
#[ORM\Column(length: 255, nullable: true)]
private ?string $baseURL = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $returnURL = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $cancelURL = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $publicKeySandBox = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $secretKeySandBox = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $baseURLSandBox = null;
#[ORM\Column(nullable: true)]
private ?bool $isSandBoxEnabled = null;
#[ORM\ManyToMany(targetEntity: Country::class, inversedBy: 'paymentMethods')]
private Collection $includedCountries;
#[ORM\ManyToMany(targetEntity: Product::class, mappedBy: 'includedPaymentMethods')]
private Collection $products;
public function __construct()
{
$this->payments = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->invoices = new ArrayCollection();
$this->includedCountries = new ArrayCollection();
$this->products = new ArrayCollection();
}
public function __toString(): string
{
return (string)$this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getIsEnabled(): ?bool
{
return $this->isEnabled;
}
public function setIsEnabled(?bool $isEnabled): self
{
$this->isEnabled = $isEnabled;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
/**
* @return Collection|Payment[]
*/
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): self
{
if (!$this->payments->contains($payment)) {
$this->payments[] = $payment;
$payment->setPaymentMethod($this);
}
return $this;
}
public function removePayment(Payment $payment): self
{
if ($this->payments->removeElement($payment)) {
// set the owning side to null (unless already changed)
if ($payment->getPaymentMethod() === $this) {
$payment->setPaymentMethod(null);
}
}
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setPaymentMethod($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getPaymentMethod() === $this) {
$order->setPaymentMethod(null);
}
}
return $this;
}
/**
* @return Collection<int, Invoice>
*/
public function getInvoices(): Collection
{
return $this->invoices;
}
public function addInvoice(Invoice $invoice): self
{
if (!$this->invoices->contains($invoice)) {
$this->invoices->add($invoice);
$invoice->setPaymentMethod($this);
}
return $this;
}
public function removeInvoice(Invoice $invoice): self
{
if ($this->invoices->removeElement($invoice)) {
// set the owning side to null (unless already changed)
if ($invoice->getPaymentMethod() === $this) {
$invoice->setPaymentMethod(null);
}
}
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getSecretKey(): ?string
{
return $this->secretKey;
}
public function setSecretKey(?string $secretKey): self
{
$this->secretKey = $secretKey;
return $this;
}
public function getPublicKey(): ?string
{
return $this->publicKey;
}
public function setPublicKey(?string $publicKey): self
{
$this->publicKey = $publicKey;
return $this;
}
public function getDisplayOn(): array
{
return $this->displayOn;
}
public function setDisplayOn(?array $displayOn): self
{
$this->displayOn = $displayOn;
return $this;
}
public function getBaseURL(): ?string
{
return $this->baseURL;
}
public function setBaseURL(?string $baseURL): static
{
$this->baseURL = $baseURL;
return $this;
}
public function getReturnURL(): ?string
{
return $this->returnURL;
}
public function setReturnURL(?string $returnURL): static
{
$this->returnURL = $returnURL;
return $this;
}
public function getCancelURL(): ?string
{
return $this->cancelURL;
}
public function setCancelURL(?string $cancelURL): static
{
$this->cancelURL = $cancelURL;
return $this;
}
public function getPublicKeySandBox(): ?string
{
return $this->publicKeySandBox;
}
public function setPublicKeySandBox(?string $publicKeySandBox): static
{
$this->publicKeySandBox = $publicKeySandBox;
return $this;
}
public function getSecretKeySandBox(): ?string
{
return $this->secretKeySandBox;
}
public function setSecretKeySandBox(?string $secretKeySandBox): static
{
$this->secretKeySandBox = $secretKeySandBox;
return $this;
}
public function getBaseURLSandBox(): ?string
{
return $this->baseURLSandBox;
}
public function setBaseURLSandBox(?string $baseURLSandBox): static
{
$this->baseURLSandBox = $baseURLSandBox;
return $this;
}
public function isSandBoxEnabled(): ?bool
{
return $this->isSandBoxEnabled;
}
public function setIsSandBoxEnabled(?bool $isSandBoxEnabled): static
{
$this->isSandBoxEnabled = $isSandBoxEnabled;
return $this;
}
/**
* @return Collection<int, Country>
*/
public function getIncludedCountries(): Collection
{
return $this->includedCountries;
}
public function addIncludedCountry(Country $includedCountry): static
{
if (!$this->includedCountries->contains($includedCountry)) {
$this->includedCountries->add($includedCountry);
}
return $this;
}
public function removeIncludedCountry(Country $includedCountry): static
{
$this->includedCountries->removeElement($includedCountry);
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): static
{
if (!$this->products->contains($product)) {
$this->products->add($product);
$product->addIncludedPaymentMethod($this);
}
return $this;
}
public function removeProduct(Product $product): static
{
if ($this->products->removeElement($product)) {
$product->removeIncludedPaymentMethod($this);
}
return $this;
}
}