@@ -218,6 +218,7 @@ private function getDefaultData(): array
218
218
* @param Type $entityType
219
219
* @return array
220
220
* @throws \Magento\Framework\Exception\LocalizedException
221
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
221
222
*/
222
223
private function getAttributesMeta (Type $ entityType ): array
223
224
{
@@ -226,25 +227,17 @@ private function getAttributesMeta(Type $entityType): array
226
227
$ attributes = $ entityType ->getAttributeCollection ();
227
228
$ customerId = $ this ->context ->getRequestParam ('parent_id ' );
228
229
$ entityId = $ this ->context ->getRequestParam ('entity_id ' );
229
-
230
+ $ customerStreetAddressLines = 0 ;
230
231
if (!$ customerId && $ entityId ) {
231
232
$ customerId = $ this ->addressRegistry ->retrieve ($ entityId )->getParentId ();
233
+ $ customerStreetAddress = $ this ->addressRegistry ->retrieve ($ entityId )->getStreet ();
234
+ $ customerStreetAddressLines = count ($ customerStreetAddress );
232
235
}
233
236
234
237
if ($ customerId ) {
235
238
$ customer = $ this ->customerRepository ->getById ($ customerId );
236
239
$ attributes ->setWebsite ($ customer ->getWebsiteId ());
237
240
}
238
- $ customerAddress = $ customer ->getAddresses ()[0 ];
239
-
240
- $ customerStreetAddressLines = 0 ;
241
- if ($ customerAddress !== null ){
242
- $ customerStreetAddress = $ customerAddress ->getStreet ();
243
- if ($ customerStreetAddress !== null ){
244
- $ customerStreetAddressLines = count ($ customerStreetAddress );
245
- }
246
- }
247
-
248
241
/* @var AbstractAttribute $attribute */
249
242
foreach ($ attributes as $ attribute ) {
250
243
if (\in_array ($ attribute ->getFrontendInput (), $ this ->bannedInputTypes , true )) {
@@ -253,16 +246,16 @@ private function getAttributesMeta(Type $entityType): array
253
246
if (\in_array ($ attribute ->getAttributeCode (), self ::$ attributesToEliminate , true )) {
254
247
continue ;
255
248
}
256
-
257
- $ attributeCode = $ attribute ->getAttributeCode ();
258
- $ meta [$ attributeCode ] = $ this ->attributeMetadataResolver ->getAttributesMeta (
249
+ $ meta [$ attribute ->getAttributeCode ()] = $ this ->attributeMetadataResolver ->getAttributesMeta (
259
250
$ attribute ,
260
251
$ entityType ,
261
252
$ this ->allowToShowHiddenAttributes
262
253
);
263
- if ($ attributeCode === 'street ' && $ customerStreetAddressLines !== 0 ){
264
- $ meta [$ attributeCode ]["arguments " ]["data " ]["config " ]["size " ] = max (
265
- $ meta [$ attributeCode ]["arguments " ]["data " ]["config " ]["size " ],$ customerStreetAddressLines );
254
+ if ($ attribute ->getAttributeCode () === 'street ' && $ customerStreetAddressLines !== 0 ) {
255
+ $ meta [$ attribute ->getAttributeCode ()]["arguments " ]["data " ]["config " ]["size " ] = max (
256
+ $ meta [$ attribute ->getAttributeCode ()]["arguments " ]["data " ]["config " ]["size " ],
257
+ $ customerStreetAddressLines
258
+ );
266
259
}
267
260
}
268
261
$ this ->attributeMetadataResolver ->processWebsiteMeta ($ meta );
0 commit comments