diff --git a/src/Entity/GatewayCheckout.php b/src/Entity/GatewayCheckout.php index 3127188..c97afc3 100644 --- a/src/Entity/GatewayCheckout.php +++ b/src/Entity/GatewayCheckout.php @@ -71,9 +71,19 @@ class GatewayCheckout #[ORM\Column(length: 255)] private ?string $gateway = null; + /** + * A list of URLs provided by the Gateway for this checkout.\ + * e.g: Fulfill payment, API resource address. + * + * @var Collection + */ + #[API\ApiProperty(writable: false)] + #[ORM\OneToMany(mappedBy: 'checkout', targetEntity: GatewayLink::class, cascade: ['persist'])] + private Collection $gatewayLinks; + /** * A list of tracking codes provided by the Gateway for this checkout.\ - * e.g: Order ID, Payment Capture ID, Checkout Session Token + * e.g: Order ID, Payment Capture ID, Checkout Session Token. * * @var Collection */ @@ -81,15 +91,6 @@ class GatewayCheckout #[ORM\OneToMany(mappedBy: 'checkout', targetEntity: GatewayTracking::class, cascade: ['persist'])] private Collection $gatewayTrackings; - /** - * The URLs provided by the Gateway for this checkout. - * - * @var Collection - */ - #[API\ApiProperty(writable: false)] - #[ORM\OneToMany(mappedBy: 'checkout', targetEntity: GatewayCheckoutLink::class, cascade: ['persist'])] - private Collection $gatewayLinks; - /** * GatewayCheckout was migrated from an invest record in Goteo v3 platform. */ @@ -183,6 +184,36 @@ class GatewayCheckout return $this; } + /** + * @return Collection + */ + public function getGatewayLinks(): Collection + { + return $this->gatewayLinks; + } + + public function addGatewayLink(GatewayLink $link): static + { + if (!$this->gatewayLinks->contains($link)) { + $this->gatewayLinks->add($link); + $link->setCheckout($this); + } + + return $this; + } + + public function removeGatewayLink(GatewayLink $link): static + { + if ($this->gatewayLinks->removeElement($link)) { + // set the owning side to null (unless already changed) + if ($link->getCheckout() === $this) { + $link->setCheckout(null); + } + } + + return $this; + } + /** * @return Collection */ @@ -213,36 +244,6 @@ class GatewayCheckout return $this; } - /** - * @return Collection - */ - public function getGatewayLinks(): Collection - { - return $this->gatewayLinks; - } - - public function addGatewayLink(GatewayCheckoutLink $link): static - { - if (!$this->gatewayLinks->contains($link)) { - $this->gatewayLinks->add($link); - $link->setCheckout($this); - } - - return $this; - } - - public function removeGatewayLink(GatewayCheckoutLink $link): static - { - if ($this->gatewayLinks->removeElement($link)) { - // set the owning side to null (unless already changed) - if ($link->getCheckout() === $this) { - $link->setCheckout(null); - } - } - - return $this; - } - public function isMigrated(): ?bool { return $this->migrated; diff --git a/src/Entity/GatewayCheckoutLink.php b/src/Entity/GatewayLink.php similarity index 85% rename from src/Entity/GatewayCheckoutLink.php rename to src/Entity/GatewayLink.php index 9ff892a..86db39b 100644 --- a/src/Entity/GatewayCheckoutLink.php +++ b/src/Entity/GatewayLink.php @@ -3,12 +3,12 @@ namespace App\Entity; use ApiPlatform\Metadata as API; -use App\Repository\GatewayCheckoutLinkRepository; +use App\Repository\GatewayLinkRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; -#[ORM\Entity(repositoryClass: GatewayCheckoutLinkRepository::class)] -class GatewayCheckoutLink +#[ORM\Entity(repositoryClass: GatewayLinkRepository::class)] +class GatewayLink { #[ORM\Id] #[ORM\GeneratedValue] @@ -40,8 +40,8 @@ class GatewayCheckoutLink * `debug` links are for developers and platform maintainers to get useful information about the checkout.\ * `payment` links are for end-users who must visit this link to complete the checkout. */ - #[ORM\Column(enumType: GatewayCheckoutLinkType::class)] - private ?GatewayCheckoutLinkType $type = null; + #[ORM\Column(enumType: GatewayLinkType::class)] + private ?GatewayLinkType $type = null; #[API\ApiProperty(readable: false)] #[ORM\ManyToOne(inversedBy: 'links')] @@ -89,12 +89,12 @@ class GatewayCheckoutLink return $this; } - public function getType(): ?GatewayCheckoutLinkType + public function getType(): ?GatewayLinkType { return $this->type; } - public function setType(GatewayCheckoutLinkType $type): static + public function setType(GatewayLinkType $type): static { $this->type = $type; diff --git a/src/Entity/GatewayCheckoutLinkType.php b/src/Entity/GatewayLinkType.php similarity index 90% rename from src/Entity/GatewayCheckoutLinkType.php rename to src/Entity/GatewayLinkType.php index 5f00cc0..f2384b4 100644 --- a/src/Entity/GatewayCheckoutLinkType.php +++ b/src/Entity/GatewayLinkType.php @@ -2,7 +2,7 @@ namespace App\Entity; -enum GatewayCheckoutLinkType: string +enum GatewayLinkType: string { /** * A 'debug' type link indicates a link that is helpful to developers and platform maintainers to get info about the checkout. diff --git a/src/Repository/GatewayCheckoutLinkRepository.php b/src/Repository/GatewayLinkRepository.php similarity index 70% rename from src/Repository/GatewayCheckoutLinkRepository.php rename to src/Repository/GatewayLinkRepository.php index de67518..3207933 100644 --- a/src/Repository/GatewayCheckoutLinkRepository.php +++ b/src/Repository/GatewayLinkRepository.php @@ -2,22 +2,22 @@ namespace App\Repository; -use App\Entity\GatewayCheckoutLink; +use App\Entity\GatewayLink; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; /** - * @extends ServiceEntityRepository + * @extends ServiceEntityRepository */ -class GatewayCheckoutLinkRepository extends ServiceEntityRepository +class GatewayLinkRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { - parent::__construct($registry, GatewayCheckoutLink::class); + parent::__construct($registry, GatewayLink::class); } // /** - // * @return GatewayCheckoutLink[] Returns an array of GatewayCheckoutLink objects + // * @return GatewayLink[] Returns an array of GatewayLink objects // */ // public function findByExampleField($value): array // { @@ -31,7 +31,7 @@ class GatewayCheckoutLinkRepository extends ServiceEntityRepository // ; // } - // public function findOneBySomeField($value): ?GatewayCheckoutLink + // public function findOneBySomeField($value): ?GatewayLink // { // return $this->createQueryBuilder('g') // ->andWhere('g.exampleField = :val')