magespecialist / m2-MSP_APIEnhancer

Magento2 API Cache and enhancements
82 stars 29 forks source link

Remove default pathes in di.xml conf #2

Closed maximehuran closed 6 years ago

maximehuran commented 6 years ago

The problem is I cannot remove the pathes set by default in XML.

Replace in di.xml

<type name="MSP\APIEnhancer\Api\EnhancerManagementInterface">
        <arguments>
            <!--
            You can restrict rest-API cache to the following paths (regex)
            This is valid both for Varnish and non-Varnish cache
            -->
            <argument name="paths" xsi:type="array">
                <item name="products" xsi:type="string">^/rest/V1/products</item>
                <item name="categories" xsi:type="string">^/rest/V1/categories</item>
            </argument>
        </arguments>
    </type>

By the same with item commented :

<type name="MSP\APIEnhancer\Api\EnhancerManagementInterface">
        <arguments>
            <!--
            You can restrict rest-API cache to the following paths (regex)
            This is valid both for Varnish and non-Varnish cache
            -->
            <argument name="paths" xsi:type="array">
                <!--<item name="products" xsi:type="string">^/rest/V1/products</item>-->
                <!--<item name="categories" xsi:type="string">^/rest/V1/categories</item>-->
            </argument>
        </arguments>
    </type>

In order to be able to remove these. Because of di merging, I can't do that :/ And you can put in README the way to configure it in our di.xml

What do you think of that ?

maximehuran commented 6 years ago

It's ok I did that on my di.xml

<type name="MSP\APIEnhancer\Api\EnhancerManagementInterface">
        <arguments>
            <!--
            You can restrict rest-API cache to the following paths (regex)
            This is valid both for Varnish and non-Varnish cache
            -->
            <argument name="paths" xsi:type="array">
                <item name="products" xsi:type="string">$^</item><!-- Impossible Regex to remove the one in /web/vendor/msp/apienhancer/etc/di.xml -->
                <item name="categories" xsi:type="string">$^</item><!-- Impossible Regex to remove the one in /web/vendor/msp/apienhancer/etc/di.xml -->
                <item name="myregex" xsi:type="string">^/rest/V1/categories/html</item><!-- My custom Regex -->
            </argument>
        </arguments>
    </type>