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?

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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.