Skip to content
Snippets Groups Projects

feat: allow advanced sorting of config schema sequences

Open Michael Lutz requested to merge issue/drupal-3298348:3298348-make-config-sequences into 11.x
1 unresolved thread

Closes #3298348

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
299 // https://www.drupal.org/project/drupal/issues/2855675
300 return $value;
301 }
302 $order_by = [$order_by];
303 }
304 // Build an argument array for array_multisort().
305 $args = [];
306 foreach ($order_by as $order) {
307 if (!is_array($order)) {
308 $order = [
309 'sort_by' => $order,
310 ];
311 }
312 $sort_array = [];
313 foreach ($value as $sequence_key => $sequence_element) {
314 $sort_array[$sequence_key] = NestedArray::getValue($sequence_element, explode(static::PROPERTY_SEPARATOR, $order['sort_by']), $key_exists);
  • Author Developer

    We can fall back to array_column() here if !str_contains($order['sort_by'], static::PROPERTY_SEPARATOR), which I suspect will be the majority of cases. I wonder if there is value in adding a NestedArray::column() method to mimic array_column() for nested arrays that can fall back to array_column() when possible.

    Edited by Michael Lutz
  • Please register or sign in to reply
Please register or sign in to reply
Loading