@@ -45,6 +45,28 @@ public function toNestedArray(
45
45
}
46
46
$ dataObjectArray = $ this ->dataObjectProcessor ->buildOutputDataArray ($ dataObject , $ dataObjectType );
47
47
//process custom attributes if present
48
+ $ dataObjectArray = $ this ->processCustomAttributes ($ dataObjectArray , $ skipAttributes );
49
+
50
+ if (!empty ($ dataObjectArray [ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY ])) {
51
+ /** @var array $extensionAttributes */
52
+ $ extensionAttributes = $ dataObjectArray [ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY ];
53
+ unset($ dataObjectArray [ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY ]);
54
+ foreach ($ extensionAttributes as $ attributeKey => $ attributeValue ) {
55
+ if (!in_array ($ attributeKey , $ skipAttributes )) {
56
+ $ dataObjectArray [$ attributeKey ] = $ attributeValue ;
57
+ }
58
+ }
59
+ }
60
+ return $ dataObjectArray ;
61
+ }
62
+
63
+ /**
64
+ * @param array $dataObjectArray
65
+ * @param array $skipAttributes
66
+ * @return array
67
+ */
68
+ private function processCustomAttributes (array $ dataObjectArray , array $ skipAttributes ): array
69
+ {
48
70
if (!empty ($ dataObjectArray [AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY ])) {
49
71
/** @var AttributeValue[] $customAttributes */
50
72
$ customAttributes = $ dataObjectArray [AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY ];
@@ -56,14 +78,9 @@ public function toNestedArray(
56
78
}
57
79
}
58
80
}
59
- if (!empty ($ dataObjectArray [ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY ])) {
60
- /** @var array $extensionAttributes */
61
- $ extensionAttributes = $ dataObjectArray [ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY ];
62
- unset($ dataObjectArray [ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY ]);
63
- foreach ($ extensionAttributes as $ attributeKey => $ attributeValue ) {
64
- if (!in_array ($ attributeKey , $ skipAttributes )) {
65
- $ dataObjectArray [$ attributeKey ] = $ attributeValue ;
66
- }
81
+ foreach ($ dataObjectArray as $ key => $ value ) {
82
+ if (is_array ($ value )) {
83
+ $ dataObjectArray [$ key ] = $ this ->processCustomAttributes ($ value , $ skipAttributes );
67
84
}
68
85
}
69
86
return $ dataObjectArray ;
0 commit comments