1

I'm following object manager argument replacement tutorial. One of the possible di.xml looks like

<type name="Pulsestorm\TutorialObjectManagerArguments\Model\Example">
 <arguments>
 <argument name="scaler1" xsi:type="string">bar</argument>
 </arguments>
</type>

Which means in Model Example's class's constructor, replace (whatever old) value of argument $scaler1 with bar.

Whereas for commands it looks like

<type name="Magento\Framework\Console\CommandList">
 <arguments>
 <argument name="commands" xsi:type="array">
 <item name="testbedCommand" xsi:type="object">Pulsestorm\TutorialObjectManagerArguments\Command\Testbed</item>
 </argument>
 </arguments>
</type>

Which says add 1 new item(command) in CommandList's constructor argument commands(which is of array type).

I don't see use of the name testbedCommand anywhere in the module. What will be it's usage ? Should it be unique?

asked Feb 5, 2016 at 7:18

1 Answer 1

1

An item name is not used in Magento\Framework\Console\CommandList. If you look into this class, you can see, that only values are used, however array keys are also available.

If you define in your module the same type and with same argument item name:

<type name="Magento\Framework\Console\CommandList">
 <arguments>
 <argument name="commands" xsi:type="array">
 <item name="testbedCommand" xsi:type="object">Your\Module\Command\Testbed</item>
 </argument>
 </arguments>
</type>

and you module goes after Pulsestorm\TutorialObjectManagerArguments, then as the argument you will get your value:

 <argument name="commands" xsi:type="array">
 <item name="testbedCommand" xsi:type="object">Your\Module\Command\Testbed</item>
 </argument>
answered Feb 15, 2016 at 14:03

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.