Skip to content

[DEFAULT ORDER] #1246: Support default order for a specific custom operation #3784

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

Merged
merged 2 commits into from
Nov 8, 2020
Merged

[DEFAULT ORDER] #1246: Support default order for a specific custom operation #3784

merged 2 commits into from
Nov 8, 2020

Conversation

ahmed-bhs
Copy link
Contributor

@ahmed-bhs ahmed-bhs commented Oct 24, 2020

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tickets #1321
License MIT
Doc PR api-platform/docs#1195

Currently, the default-order impact all the defined collection operations, so, it is not possible to have two different custom operations with different default-order configurations.

The idea is to support both, the definition of an order in a global way and also in a more specific way.

For example:

resources:
    attributes:
        order: ["foo", "ASC"]
    App\Entity\Book:
        collectionOperations:
            get_desc:
               method: GET
               path: /books/desc
               order: ["name", "DESC"]
               normalization_context:
                    groups: ['group1']
            get_asc:
               method: GET
               path: /books/asc
               order: ["name", "ASC"]
               normalization_context:
                    groups: ['group2']
            get_another:
               method: GET
               path: /books/another
               normalization_context:
                    groups: ['group3']
  • order: ["name", "DESC"] will be applied on get_desc operation.
  • order: ["name", "ASC"] will be applied on get_asc operation.
  • order: order: ["foo", "ASC"] will be applied on get_another operation.

This will allow to have a parent generic configuration and others more specific child configuration.

@ahmed-bhs
Copy link
Contributor Author

ahmed-bhs commented Oct 29, 2020

@dunglas 🙋 Could you please take a quick look and let me know what do you think about it!

Copy link
Member

@soyuka soyuka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on the patch I just need to check with @dunglas if we can consider this a bug fix

@soyuka soyuka added the Ready label Nov 8, 2020
@dunglas
Copy link
Member

dunglas commented Nov 8, 2020

To me it's good as a new feature! Thanks for working on this @ahmed-bhs.

@soyuka soyuka merged commit 3605e6d into api-platform:master Nov 8, 2020
@soyuka
Copy link
Member

soyuka commented Nov 8, 2020

Thanks @ahmed-bhs

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

Successfully merging this pull request may close these issues.

3 participants