2

If I want to add proxy for class Psr\Log\LoggerInterface (for example it is used only in catch block, which is not reached with every request) in my di.xml I should replace it with proxy like this:

<type name="some\class\path">
    <arguments>
        <argument name="logger" xsi:type="object">Psr\Log\LoggerInterface\Proxy</argument>
    </arguments>
</type>

or I have to put class implementing/hidden by some APIs behind this interface - something like:

<type name="some\class\path">
    <arguments>
        <argument name="logger" xsi:type="object">some class implementing\hidden behind Psr\Log\LoggerInterface</argument>
    </arguments>
</type>
1

For future reference. First option should work perfectly fine.

<type name="Company\Module\Model\Customer">
    <arguments>
        <argument name="logger" xsi:type="object">Psr\Log\LoggerInterface\Proxy</argument>
    </arguments>
</type>

Same way you can also specify a plugin based on Interface.

<type name="Company\Module\Plugin\Logger">
   <plugin name="logger" type="object">Psr\Log\LoggerInterfacePlugin />
</type>

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.