Repository navigation
Adding the new SortDirection - #50
ThomasLandauer wants to merge 2 commits into
Conversation
| * $I->grabEntitiesFromRepository('User', [ | ||
| * 'status' => 'active', | ||
| * Criteria::create()->orderBy(['name' => 'asc']), | ||
| * Criteria::create()->orderBy(['name' => SortDirection::Ascending]), | ||
| * ]); |
There was a problem hiding this comment.
Your suggestion would only work with doctrine/collections version 3.1 or higher.
Should this be reflected in the docs?
| * $I->grabEntitiesFromRepository('User', [ | |
| * 'status' => 'active', | |
| * Criteria::create()->orderBy(['name' => 'asc']), | |
| * Criteria::create()->orderBy(['name' => SortDirection::Ascending]), | |
| * ]); | |
| * // doctrine/collections < 3.0 | |
| * $I->grabEntitiesFromRepository('User', [ | |
| * 'status' => 'active', | |
| * Criteria::create()->orderBy(['name' => 'asc']), | |
| * ]); | |
| * | |
| * // doctrine/collections 3.0 | |
| * $I->grabEntitiesFromRepository('User', [ | |
| * 'status' => 'active', | |
| * Criteria::create()->orderBy(['name' => \Doctrine\Common\Collections\Order::Ascending]), | |
| * ]); | |
| * | |
| * // doctrine/collections > 3.0 | |
| * $I->grabEntitiesFromRepository('User', [ | |
| * 'status' => 'active', | |
| * Criteria::create()->orderBy(['name' => \SortDirection::Ascending]), | |
| * ]); |
There was a problem hiding this comment.
Order::Ascending was never really promoted, so I'd rather not mention that at all. And \SortDirection::Ascending only works in PHP 8.6 (which isn't released yet), otherwise you'll need Symfony's polyfill.
=> So this is all a little confusing - and from my experience I'd guess that whatever we write now will stay there for the next 10 years... ;-)
But you're right that removing 'asc' completely probably wasn't the best idea. So I added it as "comment" now.
My main goal was to promote PHP's new cool SortDirection enum. I think that people who can't use that yet, will easily figure out that asc is meant for them :-)
No description provided.