Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searchfilter can not be decorated #4763

Closed
Cruiser13 opened this issue May 19, 2022 · 2 comments
Closed

Searchfilter can not be decorated #4763

Cruiser13 opened this issue May 19, 2022 · 2 comments

Comments

@Cruiser13
Copy link

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
@soyuka
Copy link
Member

soyuka commented Sep 16, 2022

implement your own, search filter is quite complicated and will probably need refactoring. If you really need the code, just copy paste.

@soyuka soyuka closed this as completed Sep 16, 2022
@soyuka
Copy link
Member

soyuka commented Mar 22, 2024

Edit #5995 will help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants