core icon indicating copy to clipboard operation
core copied to clipboard

Searchfilter can not be decorated

Open Cruiser13 opened this issue 3 years ago • 0 comments

API Platform version(s) affected: 2.6.8

Description
It looks like the ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\Searchfilter.php can not be decorated as other services in symfony.

How to reproduce

If I directly edit this file, my changes are working.

The Service definition of the original looks like this:

        <service id="api_platform.doctrine.orm.search_filter" class="ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter" public="false" abstract="true">
            <argument type="service" id="doctrine" />
            <argument>null</argument>
            <argument type="service" id="api_platform.iri_converter" />
            <argument type="service" id="api_platform.property_accessor" />
            <argument type="service" id="logger" on-invalid="ignore" />
            <argument key="$identifiersExtractor" type="service" id="api_platform.identifiers_extractor.cached" on-invalid="ignore" />
            <argument key="$nameConverter" type="service" id="api_platform.name_converter" on-invalid="ignore" />
        </service>
        <service id="ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter" alias="api_platform.doctrine.orm.search_filter" />

I duplicated the file with my changes, moved it to App\Api\Core\Bridge\Doctrine\Orm\Filter\SearchFilter.php and added this to my services.yaml:

    App\Api\Core\Bridge\Doctrine\Orm\Filter\SearchFilter:
        decorates: api_platform.doctrine.orm.search_filter

After that I reverted the changes on the original file. My changes are now no longer working, it looks as if my new file is completely ignored.

But if I run php bin/console debug:container api_platform.doctrine.orm.search_filter

I do get:

// This service is a private alias for the service
// App\Api\Core\Bridge\Doctrine\Orm\Filter\SearchFilter

Overriding other services in the same way does work just fine:

    App\Api\Doctrine\DataProvider\ItemDataProvider:
        decorates: api_platform.doctrine.orm.default.item_data_provider

Cruiser13 avatar May 19 '22 14:05 Cruiser13