Skip to content

Commit 8336279

Browse files
[Maintenance] Deprecate PaymentProvider in favour of PaypalPaymentQuery
1 parent 9240a8e commit 8336279

File tree

7 files changed

+104
-5
lines changed

7 files changed

+104
-5
lines changed

src/Controller/CancelPayPalCheckoutPaymentAction.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,30 @@
2323
final class CancelPayPalCheckoutPaymentAction
2424
{
2525
public function __construct(
26-
private PaymentProviderInterface $paymentProvider,
26+
private ?PaymentProviderInterface $paymentProvider,
2727
private PaymentStateManagerInterface $paymentStateManager,
2828
private ?PaypalPaymentQueryInterface $paypalPaymentQuery = null,
2929
) {
30+
if (null !== $this->paymentProvider) {
31+
trigger_deprecation(
32+
'sylius/paypal-plugin',
33+
'1.7',
34+
sprintf(
35+
'Passing an instance of "%s" as the first argument is deprecated and will be prohibited in 3.0',
36+
PaymentProviderInterface::class,
37+
),
38+
);
39+
}
40+
if (null === $this->paypalPaymentQuery) {
41+
trigger_deprecation(
42+
'sylius/paypal-plugin',
43+
'1.7',
44+
sprintf(
45+
'Not passing an instance of "%s" is deprecated and will be prohibited in 3.0',
46+
PaypalPaymentQueryInterface::class,
47+
),
48+
);
49+
}
3050
}
3151

3252
public function __invoke(Request $request): Response

src/Controller/CancelPayPalPaymentAction.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
final class CancelPayPalPaymentAction
3232
{
3333
public function __construct(
34-
private readonly PaymentProviderInterface $paymentProvider,
34+
private readonly ?PaymentProviderInterface $paymentProvider,
3535
private readonly ObjectManager $objectManager,
3636
private readonly FlashBag|RequestStack $flashBagOrRequestStack,
3737
private readonly FactoryInterface|StateMachineInterface $stateMachineFactory,
@@ -53,6 +53,26 @@ public function __construct(
5353
),
5454
);
5555
}
56+
if (null !== $this->paymentProvider) {
57+
trigger_deprecation(
58+
'sylius/paypal-plugin',
59+
'1.7',
60+
sprintf(
61+
'Passing an instance of "%s" as the first argument is deprecated and will be prohibited in 3.0',
62+
PaymentProviderInterface::class,
63+
),
64+
);
65+
}
66+
if (null === $this->paypalPaymentQuery) {
67+
trigger_deprecation(
68+
'sylius/paypal-plugin',
69+
'1.7',
70+
sprintf(
71+
'Not passing an instance of "%s" is deprecated and will be prohibited in 3.0',
72+
PaypalPaymentQueryInterface::class,
73+
),
74+
);
75+
}
5676
}
5777

5878
public function __invoke(Request $request): Response

src/Controller/UpdatePayPalOrderAction.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
final class UpdatePayPalOrderAction
3232
{
3333
public function __construct(
34-
private readonly PaymentProviderInterface $paymentProvider,
34+
private readonly ?PaymentProviderInterface $paymentProvider,
3535
private readonly CacheAuthorizeClientApiInterface $authorizeClientApi,
3636
private readonly ?OrderDetailsApiInterface $orderDetailsApi,
3737
private readonly UpdateOrderApiInterface $updateOrderApi,
@@ -49,6 +49,26 @@ public function __construct(
4949
),
5050
);
5151
}
52+
if (null !== $this->paymentProvider) {
53+
trigger_deprecation(
54+
'sylius/paypal-plugin',
55+
'1.7',
56+
sprintf(
57+
'Passing an instance of "%s" as the first argument is deprecated and will be prohibited in 3.0',
58+
PaymentProviderInterface::class,
59+
),
60+
);
61+
}
62+
if (null === $this->paypalPaymentQuery) {
63+
trigger_deprecation(
64+
'sylius/paypal-plugin',
65+
'1.7',
66+
sprintf(
67+
'Not passing an instance of "%s" is deprecated and will be prohibited in 3.0',
68+
PaypalPaymentQueryInterface::class,
69+
),
70+
);
71+
}
5272
}
5373

5474
public function __invoke(Request $request): Response

src/Controller/Webhook/RefundOrderAction.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class RefundOrderAction
3232
{
3333
public function __construct(
3434
private readonly FactoryInterface|StateMachineInterface $stateMachineFactory,
35-
private readonly PaymentProviderInterface $paymentProvider,
35+
private readonly ?PaymentProviderInterface $paymentProvider,
3636
private readonly ObjectManager $paymentManager,
3737
private readonly PayPalRefundDataProviderInterface $payPalRefundDataProvider,
3838
private readonly ?PaypalPaymentQueryInterface $paypalPaymentQuery = null,
@@ -48,6 +48,26 @@ public function __construct(
4848
),
4949
);
5050
}
51+
if (null !== $this->paymentProvider) {
52+
trigger_deprecation(
53+
'sylius/paypal-plugin',
54+
'1.7',
55+
sprintf(
56+
'Passing an instance of "%s" as the second argument is deprecated and will be prohibited in 3.0',
57+
PaymentProviderInterface::class,
58+
),
59+
);
60+
}
61+
if (null === $this->paypalPaymentQuery) {
62+
trigger_deprecation(
63+
'sylius/paypal-plugin',
64+
'1.7',
65+
sprintf(
66+
'Not passing an instance of "%s" is deprecated and will be prohibited in 3.0',
67+
PaypalPaymentQueryInterface::class,
68+
),
69+
);
70+
}
5171
}
5272

5373
public function __invoke(Request $request): Response

src/Provider/PaymentProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@
1616
use Sylius\Component\Core\Model\PaymentInterface;
1717
use Sylius\Component\Core\Repository\PaymentRepositoryInterface;
1818
use Sylius\PayPalPlugin\Exception\PaymentNotFoundException;
19-
19+
use Sylius\PayPalPlugin\Repository\Query\PaypalPaymentQuery;
20+
21+
trigger_deprecation(
22+
'sylius/paypal-plugin',
23+
'1.7',
24+
'The "%s" class is deprecated and will be removed in Sylius/PayPalPlugin 3.0. Use "%s" instead.',
25+
PaymentProvider::class,
26+
PaypalPaymentQuery::class,
27+
);
28+
/** @deprecated since Sylius/PayPalPlugin 1.7 and will be removed in Sylius/PayPalPlugin 3.0. */
2029
final class PaymentProvider implements PaymentProviderInterface
2130
{
2231
private PaymentRepositoryInterface $paymentRepository;

src/Provider/PaymentProviderInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@
1515

1616
use Sylius\Component\Core\Model\PaymentInterface;
1717
use Sylius\PayPalPlugin\Exception\PaymentNotFoundException;
18+
use Sylius\PayPalPlugin\Repository\Query\PaypalPaymentQueryInterface;
1819

20+
trigger_deprecation(
21+
'sylius/paypal-plugin',
22+
'1.7',
23+
'The "%s" interface is deprecated and will be removed in Sylius/PayPalPlugin 3.0. Use "%s" instead.',
24+
PaymentProviderInterface::class,
25+
PaypalPaymentQueryInterface::class,
26+
);
27+
/** @deprecated since Sylius/PayPalPlugin 1.7 and will be removed in Sylius/PayPalPlugin 3.0. */
1928
interface PaymentProviderInterface
2029
{
2130
/** @throws PaymentNotFoundException */

src/Resources/config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
>
101101
<argument type="service" id="sylius.repository.payment" />
102102
<argument type="service" id="sylius.repository.order" />
103+
<deprecated package="sylius/paypal-plugin" version="1.7">The "%service_id%" service is deprecated since 1.7 and will be removed in 3.0.</deprecated>
103104
</service>
104105
<service id="sylius_paypal.provider.payment" alias="Sylius\PayPalPlugin\Provider\PaymentProviderInterface" />
105106

0 commit comments

Comments
 (0)