diff --git a/UPGRADE.md b/UPGRADE.md index 9a265200..5f361c4a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,8 +1,10 @@ ### UPGRADE FROM 1.5.1 to 1.6 1. Support for Sylius 1.13 has been added, it is now the recommended Sylius version to use. -2. Support for PHP 8.0 has been dropped. -3. The following constructor signatures have been changed: + +1. Support for PHP 8.0 has been dropped. + +1. The following constructor signatures have been changed: `Sylius\PayPalPlugin\Client\PayPalClient`: ```diff @@ -12,6 +14,7 @@ use Psr\Http\Message\StreamFactoryInterface; public function __construct( + - private readonly GuzzleClientInterface $client, + private readonly GuzzleClientInterface|ClientInterface $client, private readonly LoggerInterface $logger, private readonly UuidProviderInterface $uuidProvider, @@ -32,6 +35,7 @@ use Psr\Http\Message\RequestFactoryInterface; public function __construct( + - private readonly GuzzleClientInterface $client, + private readonly GuzzleClientInterface|ClientInterface $client, + private readonly ?RequestFactoryInterface $requestFactory = null, ) @@ -45,6 +49,7 @@ use Psr\Http\Message\StreamFactoryInterface; public function __construct( + - private readonly GuzzleClientInterface $client, + private readonly GuzzleClientInterface|ClientInterface $client, private readonly string $baseUrl, + private readonly ?RequestFactoryInterface $requestFactory = null, @@ -59,13 +64,15 @@ use Psr\Http\Message\RequestFactoryInterface; public function __construct( + - private readonly GuzzleClientInterface $client, + private readonly GuzzleClientInterface|ClientInterface $client, private readonly SellerWebhookRegistrarInterface $sellerWebhookRegistrar, private readonly string $url, + private readonly ?RequestFactoryInterface $requestFactory = null, ) ``` -4. Added doctrine migration for PostgreSQL. For more information, please refer to the [Sylius 1.13 UPGRADE.md](https://github.com/Sylius/Sylius/blob/1.13/UPGRADE-1.13.md) + +1. Added doctrine migration for PostgreSQL. For more information, please refer to the [Sylius 1.13 UPGRADE.md](https://github.com/Sylius/Sylius/blob/1.13/UPGRADE-1.13.md) ### UPGRADE FROM 1.3.0 to 1.3.1 diff --git a/spec/Api/WebhookApiSpec.php b/spec/Api/WebhookApiSpec.php index 68a86629..68bcce0c 100644 --- a/spec/Api/WebhookApiSpec.php +++ b/spec/Api/WebhookApiSpec.php @@ -36,7 +36,8 @@ function it_registers_webhook( StreamInterface $body ): void { - $requestFactory->createRequest('POST','http://base-url.com/v1/notifications/webhooks') + $requestFactory + ->createRequest('POST','http://base-url.com/v1/notifications/webhooks') ->willReturn($request); $client->sendRequest($request)->willReturn($response); diff --git a/src/Api/WebhookApi.php b/src/Api/WebhookApi.php index 62ffd7da..871821fe 100644 --- a/src/Api/WebhookApi.php +++ b/src/Api/WebhookApi.php @@ -26,7 +26,7 @@ public function __construct( ); } - if (null === $this->requestFactory && null === $this->streamFactory) { + if (null === $this->requestFactory || null === $this->streamFactory) { trigger_deprecation( 'sylius/paypal-plugin', '1.6', diff --git a/src/Client/PayPalClient.php b/src/Client/PayPalClient.php index eccce51e..5ab8d73c 100644 --- a/src/Client/PayPalClient.php +++ b/src/Client/PayPalClient.php @@ -51,7 +51,7 @@ public function __construct( ); } - if (null === $this->requestFactory && null === $this->streamFactory) { + if (null === $this->requestFactory || null === $this->streamFactory) { trigger_deprecation( 'sylius/paypal-plugin', '1.6', diff --git a/src/Controller/CreatePayPalOrderAction.php b/src/Controller/CreatePayPalOrderAction.php index 93d79fff..5e85e2e1 100644 --- a/src/Controller/CreatePayPalOrderAction.php +++ b/src/Controller/CreatePayPalOrderAction.php @@ -19,46 +19,54 @@ final class CreatePayPalOrderAction { public function __construct( - private readonly Payum $payum, - private readonly OrderRepositoryInterface $orderRepository, - private readonly FactoryInterface $stateMachineFactory, - private readonly ObjectManager $paymentManager, + private readonly ?Payum $payum, + private readonly ?OrderRepositoryInterface $orderRepository, + private readonly ?FactoryInterface $stateMachineFactory, + private readonly ?ObjectManager $paymentManager, private readonly PaymentStateManagerInterface $paymentStateManager, private readonly OrderProviderInterface $orderProvider, private readonly CapturePaymentResolverInterface $capturePaymentResolver, ) { - trigger_deprecation( - 'sylius/paypal-plugin', - '1.6', - sprintf( - 'Passing an instance of "%s" as the first argument is deprecated and will be prohibited in 2.0', - Payum::class, - ), - ); - trigger_deprecation( - 'sylius/paypal-plugin', - '1.6', - sprintf( - 'Passing an instance of "%s" as the second argument is deprecated and will be prohibited in 2.0', - OrderRepositoryInterface::class, - ), - ); - trigger_deprecation( - 'sylius/paypal-plugin', - '1.6', - sprintf( - 'Passing an instance of "%s" as the third argument is deprecated and will be prohibited in 2.0', - FactoryInterface::class, - ), - ); - trigger_deprecation( - 'sylius/paypal-plugin', - '1.6', - sprintf( - 'Passing an instance of "%s" as the fourth argument is deprecated and will be prohibited in 2.0', - ObjectManager::class, - ), - ); + if (null !== $this->payum) { + trigger_deprecation( + 'sylius/paypal-plugin', + '1.6', + sprintf( + 'Passing an instance of "%s" as the first argument is deprecated and will be prohibited in 2.0', + Payum::class, + ), + ); + } + if (null !== $this->orderRepository) { + trigger_deprecation( + 'sylius/paypal-plugin', + '1.6', + sprintf( + 'Passing an instance of "%s" as the second argument is deprecated and will be prohibited in 2.0', + OrderRepositoryInterface::class, + ), + ); + } + if (null !== $this->stateMachineFactory) { + trigger_deprecation( + 'sylius/paypal-plugin', + '1.6', + sprintf( + 'Passing an instance of "%s" as the third argument is deprecated and will be prohibited in 2.0', + FactoryInterface::class, + ), + ); + } + if (null !== $this->paymentManager) { + trigger_deprecation( + 'sylius/paypal-plugin', + '1.6', + sprintf( + 'Passing an instance of "%s" as the fourth argument is deprecated and will be prohibited in 2.0', + ObjectManager::class, + ), + ); + } } public function __invoke(Request $request): Response diff --git a/src/Controller/CreatePayPalOrderFromCartAction.php b/src/Controller/CreatePayPalOrderFromCartAction.php index 8af6e400..10c52dca 100644 --- a/src/Controller/CreatePayPalOrderFromCartAction.php +++ b/src/Controller/CreatePayPalOrderFromCartAction.php @@ -20,37 +20,43 @@ final class CreatePayPalOrderFromCartAction { public function __construct( - private readonly Payum $payum, - private readonly OrderRepositoryInterface $orderRepository, - private readonly FactoryInterface $stateMachineFactory, + private readonly ?Payum $payum, + private readonly ?OrderRepositoryInterface $orderRepository, + private readonly ?FactoryInterface $stateMachineFactory, private readonly ObjectManager $paymentManager, private readonly OrderProviderInterface $orderProvider, private readonly CapturePaymentResolverInterface $capturePaymentResolver, ) { - trigger_deprecation( - 'sylius/paypal-plugin', - '1.6', - sprintf( - 'Passing an instance of "%s" as the first argument is deprecated and will be prohibited in 2.0', - Payum::class, - ), - ); - trigger_deprecation( - 'sylius/paypal-plugin', - '1.6', - sprintf( - 'Passing an instance of "%s" as the second argument is deprecated and will be prohibited in 2.0', - OrderRepositoryInterface::class, - ), - ); - trigger_deprecation( - 'sylius/paypal-plugin', - '1.6', - sprintf( - 'Passing an instance of "%s" as the third argument is deprecated and will be prohibited in 2.0', - FactoryInterface::class, - ), - ); + if (null !== $this->payum) { + trigger_deprecation( + 'sylius/paypal-plugin', + '1.6', + sprintf( + 'Passing an instance of "%s" as the first argument is deprecated and will be prohibited in 2.0', + Payum::class, + ), + ); + } + if (null !== $this->orderRepository) { + trigger_deprecation( + 'sylius/paypal-plugin', + '1.6', + sprintf( + 'Passing an instance of "%s" as the second argument is deprecated and will be prohibited in 2.0', + OrderRepositoryInterface::class, + ), + ); + } + if (null !== $this->stateMachineFactory) { + trigger_deprecation( + 'sylius/paypal-plugin', + '1.6', + sprintf( + 'Passing an instance of "%s" as the third argument is deprecated and will be prohibited in 2.0', + FactoryInterface::class, + ), + ); + } } public function __invoke(Request $request): Response diff --git a/src/Listener/CompletePayPalOrderListener.php b/src/EventListener/Workflow/CompletePayPalOrderListener.php similarity index 94% rename from src/Listener/CompletePayPalOrderListener.php rename to src/EventListener/Workflow/CompletePayPalOrderListener.php index 7d62d28e..122985c1 100644 --- a/src/Listener/CompletePayPalOrderListener.php +++ b/src/EventListener/Workflow/CompletePayPalOrderListener.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Sylius\PayPalPlugin\Listener; +namespace Sylius\PayPalPlugin\EventListener\Workflow; use Sylius\Component\Core\Model\OrderInterface; use Sylius\PayPalPlugin\Processor\PayPalOrderCompleteProcessor; diff --git a/src/Listener/RefundPaymentListener.php b/src/EventListener/Workflow/RefundPaymentListener.php similarity index 94% rename from src/Listener/RefundPaymentListener.php rename to src/EventListener/Workflow/RefundPaymentListener.php index 532a4141..826690ea 100644 --- a/src/Listener/RefundPaymentListener.php +++ b/src/EventListener/Workflow/RefundPaymentListener.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Sylius\PayPalPlugin\Listener; +namespace Sylius\PayPalPlugin\EventListener\Workflow; use Sylius\Component\Core\Model\PaymentInterface; use Sylius\PayPalPlugin\Processor\PaymentRefundProcessorInterface; diff --git a/src/Resources/config/integrations/workflow.xml b/src/Resources/config/integrations/workflow.xml index c29c475b..afb24e8c 100644 --- a/src/Resources/config/integrations/workflow.xml +++ b/src/Resources/config/integrations/workflow.xml @@ -2,13 +2,13 @@ - + - + diff --git a/src/Resources/config/services/controller.xml b/src/Resources/config/services/controller.xml index cb7f9879..81e12e2d 100644 --- a/src/Resources/config/services/controller.xml +++ b/src/Resources/config/services/controller.xml @@ -64,19 +64,19 @@ - - - - + null + null + null + null - - - + null + null + null diff --git a/tests/Application/config/packages/workflow.yaml b/tests/Application/config/packages/workflow.yaml index 5decd124..3adbf63d 100644 --- a/tests/Application/config/packages/workflow.yaml +++ b/tests/Application/config/packages/workflow.yaml @@ -1,2 +1,2 @@ framework: - workflows: ~ \ No newline at end of file + workflows: ~