Skip to content

Commit 9bacb22

Browse files
authored
Merge pull request #43 from mollie/oro6
PIORO-169: Add compatiblity with ORO 6
2 parents 79457dc + 19a6c5a commit 9bacb22

16 files changed

+119
-77
lines changed

Controller/AjaxMollieController.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
use Oro\Bundle\IntegrationBundle\Entity\Channel;
66
use Oro\Bundle\IntegrationBundle\Form\Type\ChannelType;
7-
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor;
8-
use Oro\Bundle\SecurityBundle\Annotation\CsrfProtection;
7+
use Oro\Bundle\SecurityBundle\Attribute\AclAncestor;
8+
use Oro\Bundle\SecurityBundle\Attribute\CsrfProtection;
99
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
10+
use Symfony\Component\Form\FormFactoryInterface;
11+
use Symfony\Contracts\Translation\TranslatorInterface;
1012
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1113
use Symfony\Component\HttpFoundation\JsonResponse;
1214
use Symfony\Component\HttpFoundation\Request;
@@ -19,11 +21,19 @@
1921
*/
2022
class AjaxMollieController extends AbstractController
2123
{
24+
/** @var FormFactoryInterface */
25+
protected $formFactory;
26+
27+
public function __construct(FormFactoryInterface $formFactory)
28+
{
29+
$this->formFactory = $formFactory;
30+
}
31+
2232
/**
2333
* @Route("/validate-connection/{channelId}/", name="mollie_payment_validate_connection", methods={"POST"})
24-
* @AclAncestor("oro_integration_update")
25-
* @ParamConverter("channel", class="OroIntegrationBundle:Channel", options={"id" = "channelId"})
26-
* @CsrfProtection()
34+
* #[AclAncestor("oro_integration_update")]
35+
* @ParamConverter("channel", class="Oro\Bundle\IntegrationBundle\Entity\Channel", options={"id" = "channelId"})
36+
* #[CsrfProtection()]
2737
*
2838
* @param Request $request
2939
* @param Channel|null $channel
@@ -36,7 +46,7 @@ public function validateConnectionAction(Request $request, Channel $channel = nu
3646
$channel = new Channel();
3747
}
3848

39-
$form = $this->createForm(
49+
$form = $this->formFactory->create(
4050
ChannelType::class,
4151
$channel
4252
);
@@ -45,13 +55,13 @@ public function validateConnectionAction(Request $request, Channel $channel = nu
4555
if (!$form->get('transport')->get('authToken')->isValid()) {
4656
return new JsonResponse([
4757
'success' => false,
48-
'message' => $this->get('translator')->trans('mollie.payment.config.authorization.verification.fail.message'),
58+
'message' => $this->container->get(TranslatorInterface::class)->trans('mollie.payment.config.authorization.verification.fail.message'),
4959
]);
5060
}
5161

5262
return new JsonResponse([
5363
'success' => true,
54-
'message' => $this->get('translator')->trans('mollie.payment.config.authorization.verification.success.message'),
64+
'message' => $this->container->get(TranslatorInterface::class)->trans('mollie.payment.config.authorization.verification.success.message'),
5565
]);
5666
}
5767
}

Controller/PaymentLinkController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Mollie\Bundle\PaymentBundle\IntegrationCore\Infrastructure\Logger\Logger;
66
use Mollie\Bundle\PaymentBundle\Manager\AdminLinkVisitHandler;
77
use Oro\Bundle\OrderBundle\Entity\Order;
8-
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor;
8+
use Oro\Bundle\SecurityBundle\Attribute\AclAncestor;
99
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
1010
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1111
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -36,9 +36,9 @@ public function __construct(AdminLinkVisitHandler $adminLinkHandler)
3636

3737
/**
3838
* @Route("/paymentlink/generate/{orderId}", name="mollie_payment_link", methods={"GET"})
39-
* @ParamConverter("order", class="OroOrderBundle:Order", options={"id" = "orderId"})
39+
* @ParamConverter("order", class="Oro\Bundle\OrderBundle\Entity\Order", options={"id" = "orderId"})
4040
* @param Order $order
41-
* @AclAncestor("oro_order_frontend_view")
41+
* #[AclAncestor("oro_order_frontend_view")]
4242
*
4343
* @return JsonResponse|RedirectResponse
4444
* @throws \Throwable

Controller/SupportController.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Mollie\Bundle\PaymentBundle\IntegrationCore\Infrastructure\Configuration\Configuration;
66
use Mollie\Bundle\PaymentBundle\IntegrationServices\DebugService;
7-
use Oro\Bundle\SecurityBundle\Annotation\Acl;
7+
use Oro\Bundle\SecurityBundle\Attribute\Acl;
88
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
99
use Symfony\Component\HttpFoundation\BinaryFileResponse;
1010
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -43,12 +43,12 @@ public function __construct(Configuration $configService)
4343
* methods={"GET"}
4444
* )
4545
*
46-
* @Acl(
46+
* #[Acl(
4747
* id="oro_integration_view",
4848
* type="entity",
4949
* permission="VIEW",
50-
* class="OroIntegrationBundle:Channel"
51-
* )
50+
* class="Oro\Bundle\IntegrationBundle\Entity\Channel"
51+
* )]
5252
*
5353
* @return JsonResponse
5454
*/
@@ -64,12 +64,12 @@ public function getDebugStatus()
6464
* methods={"POST"}
6565
* )
6666
*
67-
* @Acl(
67+
* #[Acl(
6868
* id="oro_integration_view",
6969
* type="entity",
7070
* permission="VIEW",
71-
* class="OroIntegrationBundle:Channel"
72-
* )
71+
* class="Oro\Bundle\IntegrationBundle\Entity\Channel"
72+
* )]
7373
*
7474
* @param Request $request
7575
* @return JsonResponse
@@ -94,12 +94,12 @@ public function updateDebugStatus(Request $request)
9494
* methods={"GET"}
9595
* )
9696
*
97-
* @Acl(
97+
* #[Acl(
9898
* id="oro_integration_view",
9999
* type="entity",
100100
* permission="VIEW",
101-
* class="OroIntegrationBundle:Channel"
102-
* )
101+
* class="Oro\Bundle\IntegrationBundle\Entity\Channel"
102+
* )]
103103
*
104104
* @return BinaryFileResponse
105105
*/

EventListener/Callback/AdminLinkPaymentRedirectListener.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Oro\Bundle\PaymentBundle\Entity\PaymentTransaction;
77
use Oro\Bundle\PaymentBundle\Event\AbstractCallbackEvent;
88
use Symfony\Component\HttpFoundation\RedirectResponse;
9-
use Symfony\Component\HttpFoundation\Session\Session;
9+
use Symfony\Component\HttpFoundation\RequestStack;
1010
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1111
use Symfony\Component\Routing\RouterInterface;
1212
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -18,8 +18,10 @@
1818
*/
1919
class AdminLinkPaymentRedirectListener
2020
{
21-
/** @var Session */
22-
private $session;
21+
/**
22+
* @var RequestStack
23+
*/
24+
protected RequestStack $requestStack;
2325
/**
2426
* @var RouterInterface
2527
*/
@@ -32,16 +34,16 @@ class AdminLinkPaymentRedirectListener
3234
/**
3335
* AdminLinkPaymentRedirectListener constructor.
3436
*
35-
* @param Session $session
37+
* @param RequestStack $requestStack
3638
* @param RouterInterface $router
3739
* @param TranslatorInterface $translator
3840
*/
3941
public function __construct(
40-
Session $session,
42+
RequestStack $requestStack,
4143
RouterInterface $router,
4244
TranslatorInterface $translator
4345
) {
44-
$this->session = $session;
46+
$this->requestStack = $requestStack;
4547
$this->router = $router;
4648
$this->translator = $translator;
4749
}
@@ -62,7 +64,7 @@ public function onReturn(AbstractCallbackEvent $event)
6264
}
6365

6466
if ($paymentTransaction->isSuccessful()) {
65-
$this->session->getFlashBag()->add('success', 'oro.checkout.workflow.success.thank_you.label');
67+
$this->requestStack->getSession()?->getFlashBag()->add('success', 'oro.checkout.workflow.success.thank_you.label');
6668
$event->markSuccessful();
6769
return;
6870
}

EventListener/Callback/PaymentCheckoutCallbackListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function handleEvent(AbstractCallbackEvent $event)
105105
return;
106106
}
107107

108-
if (!$this->request->getMasterRequest()) {
108+
if (!$this->request->getMainRequest()) {
109109
Logger::logWarning(
110110
'Web hook without master HTTP request detected.',
111111
'Integration',
@@ -133,7 +133,7 @@ protected function handleEvent(AbstractCallbackEvent $event)
133133

134134
/** @var MolliePayment $paymentMethod */
135135
$paymentMethod = $this->paymentMethodProvider->getPaymentMethod($paymentMethodId);
136-
$webHookPayload = $this->request->getMasterRequest()->getContent();
136+
$webHookPayload = $this->request->getMainRequest()->getContent();
137137

138138
/** @var Order $order */
139139
$order = $this->doctrineHelper->getEntity(

EventListener/Callback/PaymentCheckoutRedirectListener.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Oro\Bundle\PaymentBundle\Method\Provider\PaymentMethodProviderInterface;
1111
use Oro\Bundle\PaymentBundle\Provider\PaymentResultMessageProviderInterface;
1212
use Symfony\Component\HttpFoundation\RedirectResponse;
13-
use Symfony\Component\HttpFoundation\Session\Session;
13+
use Symfony\Component\HttpFoundation\RequestStack;
1414
use Symfony\Component\Routing\RouterInterface;
1515

1616
/**
@@ -20,9 +20,10 @@
2020
*/
2121
class PaymentCheckoutRedirectListener
2222
{
23-
/** @var Session */
24-
private $session;
25-
23+
/**
24+
* @var RequestStack
25+
*/
26+
protected RequestStack $requestStack;
2627
/**
2728
* @var PaymentMethodProviderInterface
2829
*/
@@ -45,20 +46,20 @@ class PaymentCheckoutRedirectListener
4546
/**
4647
* PaymentCheckoutRedirectListener constructor.
4748
*
48-
* @param Session $session
49+
* @param RequestStack $requestStack
4950
* @param PaymentMethodProviderInterface $paymentMethodProvider
5051
* @param PaymentResultMessageProviderInterface $messageProvider
5152
* @param DoctrineHelper $doctrineHelper
5253
* @param RouterInterface $router
5354
*/
5455
public function __construct(
55-
Session $session,
56+
RequestStack $requestStack,
5657
PaymentMethodProviderInterface $paymentMethodProvider,
5758
PaymentResultMessageProviderInterface $messageProvider,
5859
DoctrineHelper $doctrineHelper,
5960
RouterInterface $router
6061
) {
61-
$this->session = $session;
62+
$this->requestStack = $requestStack;
6263
$this->paymentMethodProvider = $paymentMethodProvider;
6364
$this->messageProvider = $messageProvider;
6465
$this->doctrineHelper = $doctrineHelper;
@@ -110,7 +111,7 @@ public function onReturn(AbstractCallbackEvent $event)
110111
/**
111112
* @param PaymentTransaction $paymentTransaction
112113
* @param AbstractCallbackEvent $event
113-
* @param string $forceRedirectUrl
114+
* @param string $redirectUrl
114115
*/
115116
private function redirectToFailureUrl(
116117
PaymentTransaction $paymentTransaction,
@@ -131,7 +132,7 @@ private function redirectToFailureUrl(
131132
$event->markFailed();
132133
}
133134

134-
$flashBag = $this->session->getFlashBag();
135+
$flashBag = $this->requestStack->getSession()?->getFlashBag();
135136
if (!$flashBag->has('error')) {
136137
$flashBag->add('error', $this->messageProvider->getErrorMessage($paymentTransaction));
137138
}

EventListener/ChannelSettingsListener.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Mollie\Bundle\PaymentBundle\IntegrationServices\FileUploader;
1616
use Oro\Bundle\IntegrationBundle\Entity\Channel;
1717
use Symfony\Component\HttpFoundation\File\UploadedFile;
18-
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
18+
use Symfony\Component\HttpFoundation\RequestStack;
1919
use Symfony\Contracts\Translation\TranslatorInterface;
2020

2121
/**
@@ -45,9 +45,9 @@ class ChannelSettingsListener
4545
*/
4646
private $translator;
4747
/**
48-
* @var FlashBagInterface
48+
* @var RequestStack
4949
*/
50-
private $flashBag;
50+
protected RequestStack $requestStack;
5151
/**
5252
* @var string
5353
*/
@@ -61,7 +61,7 @@ class ChannelSettingsListener
6161
* @param PaymentMethodController $paymentMethodController
6262
* @param FileUploader $fileUploader
6363
* @param TranslatorInterface $translator
64-
* @param FlashBagInterface $flashBag
64+
* @param RequestStack $requestStack
6565
* @param string $publicImagePath
6666
*/
6767
public function __construct(
@@ -70,15 +70,15 @@ public function __construct(
7070
PaymentMethodController $paymentMethodController,
7171
FileUploader $fileUploader,
7272
TranslatorInterface $translator,
73-
FlashBagInterface $flashBag,
73+
RequestStack $requestStack,
7474
$publicImagePath
7575
) {
7676
$this->configService = $configService;
7777
$this->websiteProfileController = $websiteProfileController;
7878
$this->paymentMethodController = $paymentMethodController;
7979
$this->fileUploader = $fileUploader;
8080
$this->translator = $translator;
81-
$this->flashBag = $flashBag;
81+
$this->requestStack = $requestStack;
8282
$this->publicImagePath = $publicImagePath;
8383
}
8484

@@ -176,7 +176,7 @@ public function uploadImage(UploadedFile $image, $fileNamePrefix)
176176
$uploadedImageName = $this->fileUploader->upload($image, $fileNamePrefix);
177177

178178
if (!$uploadedImageName) {
179-
$this->flashBag->add(
179+
$this->requestStack->getSession()?->getFlashBag()->add(
180180
'warning',
181181
$this->translator->trans(
182182
'mollie.payment.config.payment_methods.image.upload_error',

EventListener/OrderLineEntityListener.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Mollie\Bundle\PaymentBundle\Mapper\MollieDtoMapperInterface;
1414
use Oro\Bundle\OrderBundle\Entity\OrderLineItem;
1515
use Symfony\Contracts\Translation\TranslatorInterface;
16+
use Symfony\Component\HttpFoundation\RequestStack;
1617

1718
/**
1819
* Class OrderLineEntityListener
@@ -46,11 +47,14 @@ class OrderLineEntityListener
4647
* @var OrderReferenceService
4748
*/
4849
private $orderReferenceService;
49-
5050
/**
5151
* @var bool
5252
*/
5353
private static $handleLineEvent = true;
54+
/**
55+
* @var RequestStack
56+
*/
57+
protected RequestStack $requestStack;
5458

5559
/**
5660
* OrderLineEntityListener constructor.
@@ -61,21 +65,24 @@ class OrderLineEntityListener
6165
* @param OroPaymentMethodUtility $paymentMethodUtility
6266
* @param MollieDtoMapperInterface $mollieDtoMapper
6367
* @param TranslatorInterface $translator
68+
* @param RequestStack $requestStack
6469
*/
6570
public function __construct(
6671
Configuration $configService,
6772
EventBus $eventBus,
6873
OrderReferenceService $orderReferenceService,
6974
OroPaymentMethodUtility $paymentMethodUtility,
7075
MollieDtoMapperInterface $mollieDtoMapper,
71-
TranslatorInterface $translator
76+
TranslatorInterface $translator,
77+
RequestStack $requestStack
7278
) {
7379
$this->configService = $configService;
7480
$this->eventBus = $eventBus;
7581
$this->orderReferenceService = $orderReferenceService;
7682
$this->mollieDtoMapper = $mollieDtoMapper;
7783
$this->paymentMethodUtility = $paymentMethodUtility;
7884
$this->translator = $translator;
85+
$this->requestStack = $requestStack;
7986
}
8087

8188
/**
@@ -96,6 +103,9 @@ public static function setHandleLineEvent(bool $handleLineEvent)
96103

97104
/**
98105
* @param OrderLineItem $orderLineItem
106+
* @param PreUpdateEventArgs $args
107+
*
108+
* @throws MollieOperationForbiddenException
99109
*/
100110
public function onPreUpdate(OrderLineItem $orderLineItem, PreUpdateEventArgs $args)
101111
{

0 commit comments

Comments
 (0)