문제

"Nofollow"> Object Manager 인수 교체 튜토리얼을 수행합니다.가능한 di.xml 중 하나는

처럼 보입니다.
<type name="Pulsestorm\TutorialObjectManagerArguments\Model\Example">
    <arguments>
        <argument name="scaler1" xsi:type="string">bar</argument>
    </arguments>
</type>
.

모델 Example의 클래스의 생성자를 의미하는 것은 $scaler1가있는 인수 bar의 인수의 값을 대체합니다.

명령은

처럼 보입니다.
<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>
.

CommandList의 생성자 인수 (배열 형식 인) commands (배열 유형)에 1 개의 새 항목을 추가합니다.

i testbedCommand 이름을 모듈의 모든 이름으로 사용하지 않습니다. 사용법은 무엇입니까?그것은 독특해야합니까?

도움이 되었습니까?

해결책

항목 이름은 Magento \ Framework \ Console \ commandList에서 사용되지 않습니다. 이 클래스를 살펴보면 값만 사용되거나 배열 키도 사용할 수 있습니다.

모듈에서 동일한 유형과 동일한 인수 항목 이름으로 정의한 경우 :

<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>
.

및 모듈은 pulsestorm \ tutorialObjectManagerArguments 후에 이동합니다. 그런 다음 값을 얻을 인수로 다음을 가져옵니다.

  <argument name="commands" xsi:type="array">
                <item name="testbedCommand" xsi:type="object">Your\Module\Command\Testbed</item>
  </argument>
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top