<?php
declare(strict_types=1);
namespace App\Entity\Payment;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\PaymentMethod as BasePaymentMethod;
use Sylius\Component\Payment\Model\PaymentMethodTranslationInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Core\Model\ImagesAwareInterface;
use Sylius\Component\Core\Model\ImageInterface;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_payment_method")
*/
class PaymentMethod extends BasePaymentMethod implements ImagesAwareInterface
{
/**
* @var string
*/
protected $codeGenerix;
/**
* @var string
*/
protected $codePanda;
/**
* @var boolean
*/
protected $enabledOnlyForAdmin;
/**
* @ORM\OneToMany(targetEntity=PaymentMethodImage::class, mappedBy="owner", orphanRemoval=true, cascade={"all"})
*/
protected $images;
public function __construct()
{
parent::__construct();
$this->images = new ArrayCollection();
}
public function getCodeGenerix()
{
return $this->codeGenerix;
}
public function setCodeGenerix(?string $codeGenerix): void
{
$this->codeGenerix = $codeGenerix;
}
public function getCodePanda()
{
return $this->codePanda;
}
public function setCodePanda(?string $codePanda): void
{
$this->codePanda = $codePanda;
}
public function getEnabledOnlyForAdmin()
{
return $this->enabledOnlyForAdmin;
}
public function setEnabledOnlyForAdmin(?bool $enabledOnlyForAdmin): void
{
$this->enabledOnlyForAdmin = $enabledOnlyForAdmin;
}
protected function createTranslation(): PaymentMethodTranslationInterface
{
return new PaymentMethodTranslation();
}
/**
* {@inheritdoc}
*/
public function getImages(): Collection
{
return $this->images;
}
/**
* {@inheritdoc}
*/
public function getImagesByType(string $type): Collection
{
return $this->images->filter(function (ImageInterface $image) use ($type) {
return $type === $image->getType();
});
}
/**
* {@inheritdoc}
*/
public function hasImages(): bool
{
return !$this->images->isEmpty();
}
/**
* {@inheritdoc}
*/
public function hasImage(ImageInterface $image): bool
{
return $this->images->contains($image);
}
/**
* {@inheritdoc}
*/
public function addImage(ImageInterface $image): void
{
$image->setOwner($this);
$this->images->add($image);
}
/**
* {@inheritdoc}
*/
public function removeImage(ImageInterface $image): void
{
if ($this->hasImage($image)) {
$image->setOwner(null);
$this->images->removeElement($image);
}
}
}