mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Required changes to use Symfony uid component
This commit is contained in:
parent
30d3af2d13
commit
fe5ad08276
12 changed files with 30 additions and 22 deletions
|
|
@ -24,7 +24,12 @@ final class PaymentRequestHashAwareInputCommandDataTransformer implements Comman
|
|||
/** @var PaymentRequestInterface $paymentRequest */
|
||||
$paymentRequest = $context['object_to_populate'];
|
||||
|
||||
$object->setHash($paymentRequest->getHash());
|
||||
$hash = $paymentRequest->getHash();
|
||||
if (null === $hash) {
|
||||
return $object;
|
||||
}
|
||||
|
||||
$object->setHash($hash->toBinary());
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@ final class CapturePaymentRequestHandler implements MessageHandlerInterface
|
|||
|
||||
public function __invoke(CapturePaymentRequest $capturePaymentRequest): void
|
||||
{
|
||||
$paymentRequest = $this->paymentRequestRepository->findOneByHash($capturePaymentRequest->getHash());
|
||||
$hash = $capturePaymentRequest->getHash();
|
||||
Assert::notNull($hash, 'The payment request hash cannot be null.');
|
||||
|
||||
$paymentRequest = $this->paymentRequestRepository->findOneByHash($hash);
|
||||
Assert::notNull($paymentRequest);
|
||||
|
||||
/** @var PaymentMethodInterface|null $paymentMethod */
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ final class CapturePaymentRequestCommandProvider implements PaymentRequestComman
|
|||
|
||||
public function provide(PaymentRequestInterface $paymentRequest): object
|
||||
{
|
||||
return new CapturePaymentRequest($paymentRequest->getHash());
|
||||
return new CapturePaymentRequest($paymentRequest->getHash()?->toBinary());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ final class StatusPaymentRequestCommandProvider implements PaymentRequestCommand
|
|||
|
||||
public function provide(PaymentRequestInterface $paymentRequest): object
|
||||
{
|
||||
return new StatusPaymentRequest($paymentRequest->getHash());
|
||||
return new StatusPaymentRequest($paymentRequest->getHash()?->toBinary());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ final class PaymentRequestCommandProvider implements PaymentRequestCommandProvid
|
|||
{
|
||||
public function __construct(
|
||||
private PaymentRequestDuplicationCheckerInterface $paymentRequestDuplicationChecker,
|
||||
/** @var ServiceProviderInterface<PaymentRequestCommandProviderInterface> */
|
||||
private ServiceProviderInterface $locator,
|
||||
) {
|
||||
}
|
||||
|
|
@ -53,9 +54,6 @@ final class PaymentRequestCommandProvider implements PaymentRequestCommandProvid
|
|||
Assert::notNull($gatewayConfig);
|
||||
$factoryName = $gatewayConfig->getConfig()['factory'] ?? $gatewayConfig->getFactoryName();
|
||||
|
||||
/** @var PaymentRequestCommandProviderInterface $provider */
|
||||
$provider = $this->locator->get($factoryName);
|
||||
|
||||
return $provider;
|
||||
return $this->locator->get($factoryName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,23 +19,18 @@ use Symfony\Contracts\Service\ServiceProviderInterface;
|
|||
final class PaymentRequestTypeCommandProvider implements PaymentRequestCommandProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
/** @var ServiceProviderInterface<PaymentRequestCommandProviderInterface> */
|
||||
private ServiceProviderInterface $locator,
|
||||
) {
|
||||
}
|
||||
|
||||
public function supports(PaymentRequestInterface $paymentRequest): bool
|
||||
{
|
||||
/** @var PaymentRequestCommandProviderInterface $provider */
|
||||
$provider = $this->locator->get($paymentRequest->getType());
|
||||
|
||||
return $provider->supports($paymentRequest);
|
||||
return $this->locator->get($paymentRequest->getType())->supports($paymentRequest);
|
||||
}
|
||||
|
||||
public function provide(PaymentRequestInterface $paymentRequest): object
|
||||
{
|
||||
/** @var PaymentRequestCommandProviderInterface $provider */
|
||||
$provider = $this->locator->get($paymentRequest->getType());
|
||||
|
||||
return $provider->provide($paymentRequest);
|
||||
return $this->locator->get($paymentRequest->getType())->provide($paymentRequest);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,10 @@ final class ModelPaymentRequestHandler implements MessageHandlerInterface
|
|||
|
||||
public function __invoke(PaymentRequestHashAwareInterface $command): void
|
||||
{
|
||||
$paymentRequest = $this->paymentRequestProvider->provideFromHash($command->getHash());
|
||||
$hash = $command->getHash();
|
||||
Assert::notNull($hash, 'The payment request hash cannot be null.');
|
||||
|
||||
$paymentRequest = $this->paymentRequestProvider->provideFromHash($hash);
|
||||
Assert::notNull($paymentRequest);
|
||||
|
||||
$payment = $paymentRequest->getPayment();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@ final class TokenPaymentRequestHandler implements MessageHandlerInterface
|
|||
|
||||
public function __invoke(PaymentRequestHashAwareInterface $command): void
|
||||
{
|
||||
$paymentRequest = $this->paymentRequestProvider->provideFromHash($command->getHash());
|
||||
$hash = $command->getHash();
|
||||
Assert::notNull($hash, 'The payment request hash cannot be null.');
|
||||
|
||||
$paymentRequest = $this->paymentRequestProvider->provideFromHash($hash);
|
||||
Assert::notNull($paymentRequest);
|
||||
|
||||
$token = $this->payumTokenFactory->createNew($paymentRequest);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ final class AuthorizeCommandProvider implements PaymentRequestCommandProviderInt
|
|||
|
||||
public function provide(PaymentRequestInterface $paymentRequest): object
|
||||
{
|
||||
return new AuthorizePaymentRequest($paymentRequest->getHash());
|
||||
return new AuthorizePaymentRequest($paymentRequest->getHash()?->toBinary());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ final class CaptureCommandProvider implements PaymentRequestCommandProviderInter
|
|||
|
||||
public function provide(PaymentRequestInterface $paymentRequest): object
|
||||
{
|
||||
return new CapturePaymentRequest($paymentRequest->getHash());
|
||||
return new CapturePaymentRequest($paymentRequest->getHash()?->toBinary());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ final class StatusCommandProvider implements PaymentRequestCommandProviderInterf
|
|||
|
||||
public function provide(PaymentRequestInterface $paymentRequest): object
|
||||
{
|
||||
return new StatusPaymentRequest($paymentRequest->getHash());
|
||||
return new StatusPaymentRequest($paymentRequest->getHash()?->toBinary());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace Sylius\Bundle\PaymentBundle\Doctrine\ORM;
|
|||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
|
||||
use Sylius\Component\Payment\Model\PaymentRequestInterface;
|
||||
use Sylius\Component\Payment\Repository\PaymentRequestRepositoryInterface;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
|
||||
/**
|
||||
* @template T of PaymentRequestInterface
|
||||
|
|
@ -33,7 +34,7 @@ class PaymentRequestRepository extends EntityRepository implements PaymentReques
|
|||
->andWhere('o.type = :type')
|
||||
->andWhere('o.payment = :payment')
|
||||
->andWhere('o.method = :method')
|
||||
->setParameter('paymentRequest', $paymentRequest)
|
||||
->setParameter('paymentRequest', $paymentRequest->getHash(), UuidType::NAME)
|
||||
->setParameter('type', $paymentRequest->getType())
|
||||
->setParameter('method', $paymentRequest->getMethod())
|
||||
->setParameter('payment', $paymentRequest->getPayment())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue