Skip to content

Commit 0b545cf

Browse files
committed
Merge branch 'develop' into 1.1
2 parents e87bd04 + 4f7bbdf commit 0b545cf

File tree

3 files changed

+149
-2
lines changed

3 files changed

+149
-2
lines changed

patches.json

+3
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@
370370
"magento/magento2-b2b-base": {
371371
"Layered navigation filter is present only when product is present on the listing page with enabled Shared catalog": {
372372
">=1.1.5 <1.3.1": "MCLOUD-6923__layered_navigation_filter_is_present_only_when_product_is_present_on_the_listing_page_with_enabled_shared_catalog__2.3.5.patch"
373+
},
374+
"Fields hydration on company account create request": {
375+
">=1.3.3 <1.3.3-p11 || >=1.3.4 <1.3.4-p10 || >=1.3.5 <1.3.5-p8 || >=1.4.2 <1.4.2-p3": "B2B-4051__fields_hydration_company_account_create_request__1.3.3.patch"
373376
}
374377
},
375378
"magento/magento2-ee-base": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
new file mode 100644
2+
--- /dev/null
3+
+++ b/vendor/magento/module-company/Model/Customer/AccountManagement/CompanyRequestHydrator.php
4+
@@ -0,0 +1,66 @@
5+
+<?php
6+
+/**
7+
+ * Copyright © Magento, Inc. All rights reserved.
8+
+ * See COPYING.txt for license details.
9+
+ */
10+
+declare(strict_types=1);
11+
+
12+
+namespace Magento\Company\Model\Customer\AccountManagement;
13+
+
14+
+use Magento\Company\Api\Data\CompanyInterface;
15+
+
16+
+/**
17+
+ * Getting company data form request.
18+
+ */
19+
+class CompanyRequestHydrator
20+
+{
21+
+ /**
22+
+ * @var \Magento\Framework\App\Request\Http
23+
+ */
24+
+ private $request;
25+
+ /**
26+
+ * @var array
27+
+ */
28+
+ private $fieldsToSave = [
29+
+ CompanyInterface::NAME,
30+
+ CompanyInterface::LEGAL_NAME,
31+
+ CompanyInterface::COMPANY_EMAIL,
32+
+ CompanyInterface::VAT_TAX_ID,
33+
+ CompanyInterface::RESELLER_ID,
34+
+ CompanyInterface::STREET,
35+
+ CompanyInterface::CITY,
36+
+ CompanyInterface::COUNTRY_ID,
37+
+ CompanyInterface::REGION,
38+
+ CompanyInterface::REGION_ID,
39+
+ CompanyInterface::POSTCODE,
40+
+ CompanyInterface::TELEPHONE,
41+
+ CompanyInterface::JOB_TITLE
42+
+ ];
43+
+
44+
+ /**
45+
+ * @param \Magento\Framework\App\Request\Http $request
46+
+ */
47+
+ public function __construct(
48+
+ \Magento\Framework\App\Request\Http $request,
49+
+ ) {
50+
+ $this->request = $request;
51+
+ }
52+
+
53+
+ /**
54+
+ * Get and hydrate company data from HTTP request.
55+
+ *
56+
+ * @return array
57+
+ */
58+
+ public function getCompanyDataFromRequest(): array
59+
+ {
60+
+ $result = [];
61+
+ $companyData = $this->request->getPost('company', []);
62+
+ foreach ($this->fieldsToSave as $item) {
63+
+ if (isset($companyData[$item])) {
64+
+ $result[$item] = $companyData[$item];
65+
+ }
66+
+ }
67+
+
68+
+ return $result;
69+
+ }
70+
+}
71+
--- a/vendor/magento/module-company/Plugin/Customer/Api/AccountManagement.php
72+
+++ b/vendor/magento/module-company/Plugin/Customer/Api/AccountManagement.php
73+
@@ -11,17 +11,13 @@
74+
use Magento\Customer\Api\CustomerRepositoryInterface;
75+
use Magento\Company\Api\CompanyManagementInterface;
76+
use Magento\Framework\Exception\NoSuchEntityException;
77+
+use Magento\Company\Model\Customer\AccountManagement\CompanyRequestHydrator;
78+
79+
/**
80+
* Plugin for AccountManagement. Processing company data.
81+
*/
82+
class AccountManagement
83+
{
84+
- /**
85+
- * @var \Magento\Framework\App\Request\Http
86+
- */
87+
- private $request;
88+
-
89+
/**
90+
* @var \Magento\Company\Model\Email\Sender
91+
*/
92+
@@ -47,30 +43,35 @@
93+
*/
94+
private $customerRepository;
95+
96+
+ /**
97+
+ * @var CompanyRequestHydrator
98+
+ */
99+
+ private $companyRequestHydrator;
100+
+
101+
/**
102+
* AccountManagement constructor
103+
*
104+
- * @param \Magento\Framework\App\Request\Http $request
105+
* @param \Magento\Company\Model\Email\Sender $companyEmailSender
106+
* @param \Magento\Backend\Model\UrlInterface $urlBuilder
107+
* @param \Magento\Company\Model\Customer\Company $customerCompany
108+
* @param CompanyManagementInterface $companyManagement
109+
* @param CustomerRepositoryInterface $customerRepository
110+
+ * @param CompanyRequestHydrator $companyRequestHydrator
111+
*/
112+
public function __construct(
113+
- \Magento\Framework\App\Request\Http $request,
114+
\Magento\Company\Model\Email\Sender $companyEmailSender,
115+
\Magento\Backend\Model\UrlInterface $urlBuilder,
116+
\Magento\Company\Model\Customer\Company $customerCompany,
117+
CompanyManagementInterface $companyManagement,
118+
- CustomerRepositoryInterface $customerRepository
119+
+ CustomerRepositoryInterface $customerRepository,
120+
+ CompanyRequestHydrator $companyRequestHydrator
121+
) {
122+
- $this->request = $request;
123+
$this->companyEmailSender = $companyEmailSender;
124+
$this->urlBuilder = $urlBuilder;
125+
$this->customerCompany = $customerCompany;
126+
$this->companyManagement = $companyManagement;
127+
$this->customerRepository = $customerRepository;
128+
+ $this->companyRequestHydrator = $companyRequestHydrator;
129+
}
130+
131+
/**
132+
@@ -127,11 +128,7 @@
133+
\Magento\Customer\Api\AccountManagementInterface $subject,
134+
\Magento\Customer\Api\Data\CustomerInterface $result
135+
) {
136+
- $companyData = $this->request->getPost('company', []);
137+
- if (isset($companyData['status'])) {
138+
- unset($companyData['status']);
139+
- }
140+
-
141+
+ $companyData = $this->companyRequestHydrator->getCompanyDataFromRequest();
142+
if (is_array($companyData) && !empty($companyData)) {
143+
$jobTitle = $companyData['job_title'] ?? null;
144+
$companyDataObject = $this->customerCompany->createCompany($result, $companyData, $jobTitle);

src/Test/Functional/Acceptance/PatchApplierCest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testApplyingPatch(\CliTester $I): void
4242
$targetFile = $I->grabFileContent('/target_file.md', Docker::BUILD_CONTAINER);
4343
$I->assertStringContainsString('# Hello Magento', $targetFile);
4444
$I->assertStringContainsString('## Additional Info', $targetFile);
45-
$log = $I->grabFileContent('/var/log/cloud.log', Docker::BUILD_CONTAINER);
45+
$log = $I->grabFileContent('/init/var/log/cloud.log', Docker::BUILD_CONTAINER);
4646
$I->assertStringContainsString('Patch ../m2-hotfixes/patch.patch has been applied', $log);
4747
}
4848

@@ -65,7 +65,7 @@ public function testApplyingExistingPatch(\CliTester $I): void
6565
$I->assertStringContainsString('## Additional Info', $targetFile);
6666
$I->assertStringContainsString(
6767
'Patch ../m2-hotfixes/patch.patch was already applied',
68-
$I->grabFileContent('/var/log/cloud.log', Docker::BUILD_CONTAINER)
68+
$I->grabFileContent('/init/var/log/cloud.log', Docker::BUILD_CONTAINER)
6969
);
7070
}
7171
}

0 commit comments

Comments
 (0)