-
-
Notifications
You must be signed in to change notification settings - Fork 918
Fix 1246: configure default order on ApiResource annotation #1321
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
Conversation
vincentchalamon
commented
Aug 18, 2017
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #1246 |
License | MIT |
Doc PR | api-platform/docs#235 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great feature, thanks!! I just left a small comment.
|
||
public function __construct(string $order = null) | ||
public function __construct(ResourceMetadataFactoryInterface $resourceMetadataFactory, string $order = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a BC break, can you add it as an optional last parameter?
Could you please rebase instead of merging ? |
Thank you @vincentchalamon |
* @author Vincent Chalamon <[email protected]> | ||
* | ||
* @ApiResource(attributes={ | ||
* "order"={"name", "DESC"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably have been too fast to merge. Wouldn't be better to allow complex ordering? I suggest the following:
@ApiResource(attributes={"name": "DESC", "firstname": "ASC"})
(Order by name then by firstname). WDYT @vincentchalamon? Can you do a follow up PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I though about adding the multiple default ordering, but I wasn't sure it was very useful.
I would prefer a syntax like that:
@ApiResource(attributes={
"order"={"name": "DESC", "firstname": "ASC"}
})
WDYT @dunglas? If so, I could open another PR to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's useful (ordering by name then firstname is very common for instance). You're right for the syntax, my example is faulty (missing order
key). A PR would be great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guys thank you for this feature, does this support yaml configuration, I tried to add order to my resource, seems nothing work ! Any idea? @vincentchalamon
|
@ahmed-bhs Did you try the following configuration?: resources:
App\Entity\Repos\EventFamily:
attributes:
order: ["name", "DESC"]
collectionOperations:
get: ~ I didn't try this configuration in YAML since many years (this PR is older than 3 years). |