- First commit to issue fork.
- Merge request !8525feat: allow advanced sorting of config schema sequences β (Open) created by mikelutz
- Assigned to mikelutz
- Status changed to Needs work
6 months ago 4:54pm 24 June 2024 - Issue was unassigned.
- Status changed to Needs review
6 months ago 5:16pm 24 June 2024 - πΊπΈUnited States mikelutz Michigan, USA
This one seemed like fun.
I preserved BC, so if orderby is null, or === 'key', or === 'value' existing behavior is preserved.
if orderby is a string other than 'key' or 'value' it is treated as a key inside the value. I did not require a prefix 'subkey:' as it seemed unnecessary. If you need to reference a key named 'key' or 'value' it can be done using the advanced syntax that follows. To drill down into deeper items in the sequence arrays, separate keys with a '/' (see tests). This mimics the format we use to access nested array items in the migration system.
if orderby is an array, each item is assumed to be a sort directive, and the sequence is sorted by the first, then the second, and so on. The sequence is finally sorted by the element values (while preserving keys) so as to be deterministic.
Each sort directive can be either a string, which is taken to be an element key as decribed above, or mapping containing at minimum a 'sort_by' key (containing the element key described above) and optionally 'sort_order' and 'sort_flags' keys.
sort_order and sort_flags accept as strings the constant names described here: https://www.php.net/manual/en/function.array-multisort.php sort_flags can either be a string containing a single flag, or a sequence containing multiple flags to OR together.
It would be nice if π Allow parsing and writing PHP constants and enums in YAML files Needs work were in, and we could avoid parsing the constants as strings altogether. If we don't wait, we should probably add some error checking here to ensure only the expected strings are used.
A dozenish tests are provided to test combinations of sort orders, ensure that string keys are preserved. and to demonstrate capibilities.
A new `UnsupportedSequenceSortConfigException` is provided and thrown if a sequence element does not contain a key that the schema requests that we sort on.
- Status changed to Postponed
6 months ago 10:24am 27 June 2024 - π§πͺBelgium borisson_ Mechelen, π§πͺ
This looks great. I really like the test coverage provided here. That looks like it covers all possible combinations. I think we should wait for π Allow parsing and writing PHP constants and enums in YAML files Needs work to get in.