Skip to content

Commit

Permalink
Merge branch '2.4.3-develop' of https://github.com/magento/magento2ce
Browse files Browse the repository at this point in the history
…into B2B-1832
  • Loading branch information
Roman Hanin committed Jun 7, 2021
2 parents bb8d148 + d8b6e12 commit b92eac4
Show file tree
Hide file tree
Showing 34 changed files with 1,250 additions and 35 deletions.
5 changes: 5 additions & 0 deletions app/code/Magento/Cms/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@
<argument name="path" xsi:type="string">web/default_layouts/default_cms_layout</argument>
</arguments>
</virtualType>
<type name="Magento\Cms\Model\Wysiwyg\Config">
<arguments>
<argument name="variableConfig" xsi:type="object">Magento\Variable\Model\Variable\Config\Proxy</argument>
</arguments>
</type>
</config>
122 changes: 122 additions & 0 deletions app/code/Magento/Config/Model/Config/StructureLazy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Config\Model\Config;

use Magento\Framework\ObjectManager\NoninterceptableInterface;

/**
* @inheritdoc
*/
class StructureLazy extends Structure implements NoninterceptableInterface
{
/**
* @var Structure\Data
*/
private $structureData;

/**
* @param \Magento\Config\Model\Config\Structure\Data $structureData
* @param \Magento\Config\Model\Config\Structure\Element\Iterator\Tab $tabIterator
* @param \Magento\Config\Model\Config\Structure\Element\FlyweightFactory $flyweightFactory
* @param ScopeDefiner $scopeDefiner
*/
public function __construct(
\Magento\Config\Model\Config\Structure\Data $structureData,
\Magento\Config\Model\Config\Structure\Element\Iterator\Tab $tabIterator,
\Magento\Config\Model\Config\Structure\Element\FlyweightFactory $flyweightFactory,
ScopeDefiner $scopeDefiner
) {
$this->_tabIterator = $tabIterator;
$this->_flyweightFactory = $flyweightFactory;
$this->_scopeDefiner = $scopeDefiner;
$this->structureData = $structureData;
}

/**
* @inheritdoc
*/
public function getElement($path)
{
$this->loadStructureData();
return parent::getElement($path);
}

/**
* @inheritdoc
*/
public function getTabs()
{
$this->loadStructureData();
return parent::getTabs();
}

/**
* @inheritdoc
*/
public function getSectionList()
{
$this->loadStructureData();
return parent::getSectionList();
}

/**
* @inheritdoc
*/
public function getElementByConfigPath($path)
{
$this->loadStructureData();
return parent::getElementByConfigPath($path);
}

/**
* @inheritdoc
*/
public function getFirstSection()
{
$this->loadStructureData();
return parent::getTabs();
}

/**
* @inheritdoc
*/
public function getElementByPathParts(array $pathParts)
{
$this->loadStructureData();
return parent:: getElementByPathParts($pathParts);
}

/**
* @inheritdoc
*/
public function getFieldPathsByAttribute($attributeName, $attributeValue)
{
$this->loadStructureData();
return parent::getFieldPathsByAttribute($attributeName, $attributeValue);
}

/**
* @inheritdoc
*/
public function getFieldPaths()
{
$this->loadStructureData();
return parent::getFieldPaths();
}

/**
* Load data
*/
private function loadStructureData()
{
if ($this->_data === null) {
$this->_data = $this->structureData->get();
}
}
}
5 changes: 5 additions & 0 deletions app/code/Magento/Config/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,9 @@
<argument name="structure" xsi:type="object">adminhtmlConfigStructure</argument>
</arguments>
</type>
<type name="Magento\Config\Model\Config">
<arguments>
<argument name="configStructure" xsi:type="object">\Magento\Config\Model\Config\Structure\Proxy</argument>
</arguments>
</type>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace Magento\CustomerGraphQl\Model\Context;

use Magento\Authorization\Model\UserContextInterface;
use Magento\Customer\Model\ResourceModel\CustomerRepository;
use Magento\Customer\Model\Session;
use Magento\GraphQl\Model\Query\ContextParametersInterface;
use Magento\GraphQl\Model\Query\ContextParametersProcessorInterface;

Expand All @@ -21,13 +23,29 @@ class AddUserInfoToContext implements ContextParametersProcessorInterface
*/
private $userContext;

/**
* @var Session
*/
private $session;

/**
* @var CustomerRepository
*/
private $customerRepository;

/**
* @param UserContextInterface $userContext
* @param Session $session
* @param CustomerRepository $customerRepository
*/
public function __construct(
UserContextInterface $userContext
UserContextInterface $userContext,
Session $session,
CustomerRepository $customerRepository
) {
$this->userContext = $userContext;
$this->session = $session;
$this->customerRepository = $customerRepository;
}

/**
Expand All @@ -47,7 +65,13 @@ public function execute(ContextParametersInterface $contextParameters): ContextP
}
$contextParameters->setUserType($currentUserType);

$contextParameters->addExtensionAttribute('is_customer', $this->isCustomer($currentUserId, $currentUserType));
$isCustomer = $this->isCustomer($currentUserId, $currentUserType);
$contextParameters->addExtensionAttribute('is_customer', $isCustomer);
if ($isCustomer) {
$customer = $this->customerRepository->getById($currentUserId);
$this->session->setCustomerData($customer);
$this->session->setCustomerGroupId($customer->getGroupId());
}
return $contextParameters;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CustomerGraphQl\Plugin;

use Magento\Authorization\Model\UserContextInterface;
use Magento\Customer\Model\ResourceModel\CustomerRepository;
use Magento\Customer\Model\Session as CustomerSession;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\GraphQl\Controller\GraphQl as GraphQlController;

/**
* Clear the user data out of the session object before returning the GraphQL response
*/
class ClearCustomerSessionAfterRequest
{
/**
* @var UserContextInterface
*/
private $userContext;

/**
* @var CustomerSession
*/
private $customerSession;

/**
* @var CustomerRepository
*/
private $customerRepository;

/**
* @param UserContextInterface $userContext
* @param CustomerSession $customerSession
* @param CustomerRepository $customerRepository
*/
public function __construct(
UserContextInterface $userContext,
CustomerSession $customerSession,
CustomerRepository $customerRepository
) {
$this->userContext = $userContext;
$this->customerSession = $customerSession;
$this->customerRepository = $customerRepository;
}

/**
* Clear the customer data from the session after business logic has completed
*
* @param GraphQlController $controller
* @param ResponseInterface $response
* @return ResponseInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterDispatch(GraphQlController $controller, ResponseInterface $response): ResponseInterface
{
$this->customerSession->setCustomerId(null);
$this->customerSession->setCustomerGroupId(null);
return $response;
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/CustomerGraphQl/etc/graphql/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@
</argument>
</arguments>
</type>
<type name="Magento\GraphQl\Controller\GraphQl">
<plugin name="ClearCustomerSessionAfterRequest" type="Magento\CustomerGraphQl\Plugin\ClearCustomerSessionAfterRequest" sortOrder="1" disabled="false" />
</type>
</config>
5 changes: 2 additions & 3 deletions app/code/Magento/Email/Model/Template/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ class Filter extends Template
*/
private $pubDirectoryRead;


/**
* Filter constructor.
* @param StringUtils $string
Expand Down Expand Up @@ -851,7 +850,7 @@ private function isAvailableConfigVariable($variable)
{
return in_array(
$variable,
array_column($this->configVariables->getData(), 'value')
$this->configVariables->getAvailableVars()
);
}

Expand Down Expand Up @@ -912,7 +911,7 @@ public function cssDirective($construction)
return '/*' . PHP_EOL . $exception->getMessage() . PHP_EOL . '*/';
}

if (empty($css)){
if (empty($css)) {
return '/* ' . __('Contents of the specified CSS file could not be loaded or is empty') . ' */';
}

Expand Down
11 changes: 3 additions & 8 deletions app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ class FilterTest extends TestCase
*/
private $variableResolver;

/**
* @var MockObject|VariableResolverInterface
*/
private $variableResolverInterface;

/**
* @var array
*/
Expand Down Expand Up @@ -417,7 +412,7 @@ public function testApplyInlineCssThrowsExceptionWhenDesignParamsNotSet()
public function testConfigDirectiveAvailable()
{
$path = "web/unsecure/base_url";
$availableConfigs = [['value' => $path]];
$availableConfigs = ['value' => $path];
$construction = ["{{config path={$path}}}", 'config', " path={$path}"];
$scopeConfigValue = 'value';

Expand All @@ -429,7 +424,7 @@ public function testConfigDirectiveAvailable()
$storeMock->expects($this->once())->method('getId')->willReturn(1);

$this->configVariables->expects($this->once())
->method('getData')
->method('getAvailableVars')
->willReturn($availableConfigs);
$this->scopeConfig->expects($this->once())
->method('getValue')
Expand All @@ -452,7 +447,7 @@ public function testConfigDirectiveUnavailable()
$storeMock->expects($this->once())->method('getId')->willReturn(1);

$this->configVariables->expects($this->once())
->method('getData')
->method('getAvailableVars')
->willReturn($availableConfigs);
$this->scopeConfig->expects($this->never())
->method('getValue')
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Paypal/Block/PayLater/LayoutProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ public function process($jsLayout)
{
if (!$this->payLaterConfig->isEnabled(PayLaterConfig::CHECKOUT_PAYMENT_PLACEMENT)) {
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']
['children']['payment']['children']['payments-list']['children']['before-place-order']['children']
['children']['payment']['children']['payments-list']['children']['paypal-method-extra-content']['children']
['paylater-place-order']);

return $jsLayout;
}

if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']
['children']['payment']['children']['payments-list']['children']['before-place-order']['children']
['children']['payment']['children']['payments-list']['children']['paypal-method-extra-content']['children']
['paylater-place-order'])
) {
$payLaterPlaceOrder = &$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']
['children']['payment']['children']['payments-list']['children']['before-place-order']['children']
['children']['payment']['children']['payments-list']['children']['paypal-method-extra-content']['children']
['paylater-place-order'];

$componentConfig = $payLaterPlaceOrder['config'] ?? [];
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Paypal/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
<argument name="storage" xsi:type="object">Magento\Paypal\Model\PayflowSession\Storage</argument>
</arguments>
</virtualType>
<type name="Magento\Paypal\Model\Config\StructurePlugin">
<arguments>
<argument xsi:type="object" name="backendHelper">Magento\Paypal\Helper\Backend\Proxy</argument>
</arguments>
</type>
<type name="Magento\Config\Model\Config\Structure">
<plugin name="paypal_system_configuration" type="Magento\Paypal\Model\Config\StructurePlugin"/>
</type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
<item name="children" xsi:type="array">
<item name="payments-list" xsi:type="array">
<item name="children" xsi:type="array">
<item name="before-place-order" xsi:type="array">
<item name="paypal-method-extra-content" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="displayArea" xsi:type="string">paypal-method-extra-content</item>
<item name="children" xsi:type="array">
<item name="paylater-place-order" xsi:type="array">
<item name="component" xsi:type="string">Magento_Paypal/js/view/paylater</item>
<item name="sortOrder" xsi:type="string">100</item>
<item name="displayArea" xsi:type="string">before-place-order</item>
<item name="displayArea" xsi:type="string">paypal-method-extra-content</item>
</item>
</item>
</item>
Expand Down
Loading

0 comments on commit b92eac4

Please sign in to comment.