Skip to content

Commit 3b1ac1d

Browse files
Merge remote-tracking branch '39154/fix-32987' into blprs
2 parents 488f68d + 560b3be commit 3b1ac1d

File tree

7 files changed

+121
-95
lines changed

7 files changed

+121
-95
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe.
4+
* All Rights Reserved.
5+
*/
6+
7+
declare(strict_types=1);
8+
namespace Magento\Captcha\Block;
9+
10+
use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
11+
use Magento\Captcha\Helper\Data as HelperCaptcha;
12+
13+
class CheckoutLayoutProcessor implements LayoutProcessorInterface
14+
{
15+
/**
16+
* @param HelperCaptcha $helper
17+
*/
18+
public function __construct(
19+
private readonly HelperCaptcha $helper
20+
) {
21+
}
22+
23+
/**
24+
* Remove captcha from checkout page if it is disabled
25+
*
26+
* @param array $jsLayout
27+
* @return array
28+
*/
29+
public function process($jsLayout): array
30+
{
31+
if ($this->helper->getConfig('enable')) {
32+
$captcha = [
33+
'component' => 'Magento_Captcha/js/view/checkout/loginCaptcha',
34+
'displayArea' => 'additional-login-form-fields',
35+
'formId' => 'user_login',
36+
'configSource' => 'checkoutConfig'
37+
];
38+
$jsLayout['components']['checkout']['children']['authentication']['children']['captcha'] = $captcha;
39+
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
40+
['shippingAddress']['children']['customer-email']['children']['additional-login-form-fields']
41+
['children']['captcha'] = $captcha;
42+
}
43+
return $jsLayout;
44+
}
45+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe.
4+
* All Rights Reserved.
5+
*/
6+
7+
declare(strict_types=1);
8+
namespace Magento\Captcha\Block\Customer\AuthenticationPopup;
9+
10+
use Magento\Captcha\Helper\Data as HelperCaptcha;
11+
use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
12+
13+
class LayoutProcessor implements LayoutProcessorInterface
14+
{
15+
/**
16+
* @param HelperCaptcha $helper
17+
*/
18+
public function __construct(
19+
private readonly HelperCaptcha $helper
20+
) {
21+
}
22+
23+
/**
24+
* Process jsLayout of checkout page
25+
*
26+
* @param array $jsLayout
27+
* @return array
28+
*/
29+
public function process($jsLayout): array
30+
{
31+
if ($this->helper->getConfig('enable')) {
32+
$jsLayout['components']['authenticationPopup']['children']['captcha'] = [
33+
'component' => 'Magento_Captcha/js/view/checkout/loginCaptcha',
34+
'displayArea' => 'additional-login-form-fields',
35+
'formId' => 'user_login',
36+
'configSource' => 'checkout'
37+
];
38+
}
39+
return $jsLayout;
40+
}
41+
}

app/code/Magento/Captcha/etc/frontend/di.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2015 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
@@ -37,4 +37,18 @@
3737
<type name="Magento\Sales\Api\OrderManagementInterface">
3838
<plugin name="reset_payment_attempts_after_order_is_placed_plugin" type="Magento\Captcha\Plugin\ResetPaymentAttemptsAfterOrderIsPlacedPlugin"/>
3939
</type>
40+
<type name="Magento\Checkout\Block\Onepage">
41+
<arguments>
42+
<argument name="layoutProcessors" xsi:type="array">
43+
<item name="captcha_processor" xsi:type="object">Magento\Captcha\Block\CheckoutLayoutProcessor</item>
44+
</argument>
45+
</arguments>
46+
</type>
47+
<type name="Magento\Customer\Block\Account\AuthenticationPopup">
48+
<arguments>
49+
<argument name="layoutProcessors" xsi:type="array">
50+
<item name="authentication_popup_processor" xsi:type="object">Magento\Captcha\Block\Customer\AuthenticationPopup\LayoutProcessor</item>
51+
</argument>
52+
</arguments>
53+
</type>
4054
</config>

app/code/Magento/Captcha/view/frontend/layout/checkout_index_index.xml

Lines changed: 0 additions & 59 deletions
This file was deleted.

app/code/Magento/Captcha/view/frontend/layout/default.xml

Lines changed: 0 additions & 29 deletions
This file was deleted.

app/code/Magento/Customer/Block/Account/AuthenticationPopup.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe.
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Customer\Block\Account;
77

8+
use Magento\Framework\App\ObjectManager;
89
use Magento\Customer\Model\Form;
910
use Magento\Store\Model\ScopeInterface;
11+
use Magento\Customer\Model\Context;
12+
use Magento\Framework\App\Http\Context as HttpContext;
1013

1114
/**
1215
* @api
@@ -24,21 +27,29 @@ class AuthenticationPopup extends \Magento\Framework\View\Element\Template
2427
*/
2528
private $serializer;
2629

30+
/**
31+
* @var array
32+
*/
33+
private $layoutProcessors;
34+
2735
/**
2836
* @param \Magento\Framework\View\Element\Template\Context $context
2937
* @param array $data
3038
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
39+
* @param array $layoutProcessors
3140
* @throws \RuntimeException
3241
*/
3342
public function __construct(
3443
\Magento\Framework\View\Element\Template\Context $context,
3544
array $data = [],
36-
?\Magento\Framework\Serialize\Serializer\Json $serializer = null
45+
?\Magento\Framework\Serialize\Serializer\Json $serializer = null,
46+
array $layoutProcessors = []
3747
) {
3848
parent::__construct($context, $data);
3949
$this->jsLayout = isset($data['jsLayout']) && is_array($data['jsLayout']) ? $data['jsLayout'] : [];
4050
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
4151
->get(\Magento\Framework\Serialize\Serializer\Json::class);
52+
$this->layoutProcessors = $layoutProcessors;
4253
}
4354

4455
/**
@@ -48,6 +59,9 @@ public function __construct(
4859
*/
4960
public function getJsLayout()
5061
{
62+
foreach ($this->layoutProcessors as $processor) {
63+
$this->jsLayout = $processor->process($this->jsLayout);
64+
}
5165
return $this->serializer->serialize($this->jsLayout);
5266
}
5367

app/code/Magento/Customer/Model/Form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe.
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Customer\Model;

0 commit comments

Comments
 (0)