Skip to content

Commit

Permalink
Use consistent event args; convert to new sort config first (fix #1994)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Jan 30, 2023
1 parent 065285d commit f5da39a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions application/src/View/Helper/SortSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class SortSelector extends AbstractHelper
*/
public function __invoke($sortBy, $partialName = null)
{
// Convert to the new sort configuration structure.
$sortConfig = [];
foreach ($sortBy as $sortByOption) {
$sortConfig[$sortByOption['value']] = $sortByOption['label'];
}

$partialName = $partialName ?: self::PARTIAL_NAME;

$view = $this->getView();
Expand All @@ -30,19 +36,12 @@ public function __invoke($sortBy, $partialName = null)
$sortOrderQuery = $params->fromQuery('sort_order');

$args = [
'sortBy' => $sortBy,
'sortConfig' => $sortConfig,
'sortByQuery' => $sortByQuery,
'sortOrderQuery' => $sortOrderQuery,
];
$args = $view->trigger('view.sort-selector', $args, true);

// Convert to the new sort configuration structure.
$sortConfig = [];
foreach ($args['sortBy'] as $sortBy) {
$sortConfig[$sortBy['value']] = $sortBy['label'];
}
$args['sortConfig'] = $sortConfig;

return $view->partial($partialName, (array) $args);
}
}

0 comments on commit f5da39a

Please sign in to comment.