Skip to content

feat(doctrine): doctrine filters like laravel eloquent filters #6775

New issue

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

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

Already on GitHub? # to your account

Conversation

vinceAmstoutz
Copy link
Contributor

@vinceAmstoutz vinceAmstoutz commented Nov 5, 2024

Q A
Branch? main
License MIT
Doc PR Coming soon

Completes #6749.

Goal:

Using Dotrine filters as we use Laravel Eloquent filters. Example using a BooleanFilter with Symfony and Doctrine:

#[ApiResource]
#[GetCollection(
    parameters: [
        'active' => new QueryParameter(
            filter: new BooleanFilter(),
        ),

        // support also for filter aliasing
        'enabled' => new QueryParameter(
            filter: new BooleanFilter(),
            property: 'active',
        ),
    ],
)]
#[ORM\Entity]
class FilteredBooleanParameter {
    // ...
}

TODO:

  • BooleanFilter
  • DateFilter
  • RangeFilter
  • Numeric
  • Exists
  • OrderFilter

Will be done in another PR:

@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch from fd22d9c to 93b3226 Compare November 5, 2024 13:07
@vinceAmstoutz vinceAmstoutz changed the title feat(doctrine): doctrine filters like laravel filters feat(doctrine): doctrine filters like laravel eloquent filters Nov 5, 2024
@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch from 93b3226 to 6cfee88 Compare November 6, 2024 13:15
@vinceAmstoutz
Copy link
Contributor Author

@soyuka As requested, the swagger UI doc looks like this for the DateFilter:
image

@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch 6 times, most recently from 77cb4c6 to fc7f5f1 Compare November 7, 2024 15:08
@vinceAmstoutz
Copy link
Contributor Author

@soyuka As requested, the swagger UI doc looks like this for the RangeFilter:

image

@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch 3 times, most recently from 2f4ec07 to 8f0620e Compare November 12, 2024 11:01
@vinceAmstoutz vinceAmstoutz requested a review from soyuka November 12, 2024 11:02
@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch 14 times, most recently from 68d2dfb to 3736645 Compare November 13, 2024 13:11
@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch from 3736645 to 74919ff Compare November 13, 2024 13:59
@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch from 74919ff to 4456cb1 Compare November 18, 2024 11:06
@vinceAmstoutz vinceAmstoutz requested a review from soyuka November 18, 2024 11:07
@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch from 4456cb1 to 7513e53 Compare November 18, 2024 13:02
@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch from 7513e53 to eb9277d Compare November 22, 2024 14:13
@soyuka soyuka force-pushed the feat-doctrine-filters-like-laravel-filters branch from eb9277d to db108d5 Compare December 9, 2024 13:04
@soyuka soyuka force-pushed the feat-doctrine-filters-like-laravel-filters branch from db108d5 to d9bc540 Compare December 9, 2024 13:22
@vinceAmstoutz vinceAmstoutz force-pushed the feat-doctrine-filters-like-laravel-filters branch from 7047de6 to 3dde14a Compare December 10, 2024 11:01
@vinceAmstoutz vinceAmstoutz requested a review from soyuka December 10, 2024 11:07
@soyuka soyuka force-pushed the feat-doctrine-filters-like-laravel-filters branch from e8b6dd9 to d1ffc14 Compare December 10, 2024 12:32
@soyuka soyuka merged commit f67f6f1 into api-platform:main Dec 10, 2024
59 checks passed
@vinceAmstoutz vinceAmstoutz deleted the feat-doctrine-filters-like-laravel-filters branch December 10, 2024 12:47
vinceAmstoutz added a commit to vinceAmstoutz/api-platform-core that referenced this pull request Dec 24, 2024
…platform#6775)

* feat(doctrine): doctrine filters like laravel eloquent filters

* fix: allow multiple validation with :property placeholder

* fix: correct escape filter condition

* fix: remove duplicated block

---------

Co-authored-by: soyuka <soyuka@users.noreply.github.com>
@1ed
Copy link

1ed commented Dec 28, 2024

@vinceAmstoutz @soyuka I think, composer.json files should be updated to require the minimum version which contains the new symbols. For example for doctrine-orm and doctrine-odm should be

"api-platform/doctrine-common": "^4.1"

@vinceAmstoutz
Copy link
Contributor Author

@vinceAmstoutz @soyuka I think, composer.json files should be updated to require the minimum version which contains the new symbols. For example for doctrine-orm and doctrine-odm should be

"api-platform/doctrine-common": "^4.1"

Why we should do that? @1ed

@1ed
Copy link

1ed commented Dec 28, 2024

Because new symbols like ManagerRegistryAwareInterface were introduced in api-platform/doctrine-common and then used (in a way which is not backward compatible) in eg. api-platform/doctrine-orm which makes api-platform/doctrine-orm: ^4.1 incompatible with all the versions of api-platform/doctrine-common before the interface was defined eg. <4.1 and IMHO this should be reflected in the package constrains, as the package is now broken with api-platform/doctrine-common: <4.1. And that stands for the other packages too.

GromNaN added a commit to GromNaN/api-platform-core that referenced this pull request Jan 30, 2025
interface ManagerRegistryAwareInterface implemeted by ApiPlatform\Doctrine\{Orm,Odm}\Filter\AbstractFilter

api-platform#6775
jonerickson pushed a commit to jonerickson/core that referenced this pull request Feb 21, 2025
…latform#6775)

* feat(doctrine): doctrine filters like laravel eloquent filters

* fix: allow multiple validation with :property placeholder

* fix: correct escape filter condition

* fix: remove duplicated block

---------

Co-authored-by: soyuka <soyuka@users.noreply.github.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants