0

Alan has written a great tutorial object manager argument replacement through di.xml . Everything works fine for me except nested arrays:

<type name="Pulsestorm\TutorialObjectManagerArguments\Model\Example">
 <arguments>
 <argument name="thearray" xsi:type="array">
 <item name="baz" xsi:type="string">
 <item name="0" xsi:type="string">one</item>
 <item name="1" xsi:type="string">two</item>
 </item>
 </argument>
 </arguments>
</type>

After using above di.xml configuration and running php bin/magento ps:tutorial-object-manager-arguments it says

There are no commands defined in the "ps" namespace

I'm missing something or the process of nesting arrays is changed now ?

asked Feb 3, 2016 at 13:56

1 Answer 1

1

Seems this error related to bin/magento utility. It tries to find command "tutorial-object-manager-arguments" in "ps". It is possible, that you have not installed a module or something went wrong with the module.

UPD. baz cannot be a string, it should be an array

<type name="Pulsestorm\TutorialObjectManagerArguments\Model\Example">
 <arguments>
 <argument name="thearray" xsi:type="array">
 <item name="baz" xsi:type="array">
 <item name="0" xsi:type="string">one</item>
 <item name="1" xsi:type="string">two</item>
 </item>
 </argument>
 </arguments>
</type>
answered Feb 3, 2016 at 14:05
2
  • This module is installed and working except my above configuration. After making baz to an array type, it shows other values but with error [ErrorException] Array to string conversion Commented Feb 3, 2016 at 14:57
  • 1
    maybe cause the code waits, that $thearray should contain elements that can be converted to a string. look at Command class Commented Feb 3, 2016 at 15:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.