In Magento 2 di.xml we can inject an array to a class like this:
<type name="VendorModuleModelFoo">
<arguments>
<argument name="data" xsi:type="array">
<item name="item1" xsi:type="string">Item 1</item>
<item name="item2" xsi:type="string">Item 2</item>
</argument>
<arguments>
</type>
How can we inject the same data
array to another class VendorModuleModelBar
without duplicating it like this?
<type name="VendorModuleModelBar">
<arguments>
<argument name="data" xsi:type="array">
<item name="item1" xsi:type="string">Item 1</item>
<item name="item2" xsi:type="string">Item 2</item>
</argument>
<arguments>
</type>
VirtualType only works for objects, sadly.