19declare(strict_types=1);
30 protected ?
Order $order =
null;
40 $sortable_visible_cols = array_filter(
42 static fn(
$c):
bool =>
$c->isSortable()
44 if ($sortable_visible_cols === []) {
45 return array_key_first($visible_cols);
47 return array_key_first($sortable_visible_cols);
52 $sortable_visible_cols = array_filter(
54 static fn(
$c):
bool =>
$c->isSortable()
57 if ($sortable_visible_cols === [] ||
58 ($total_count !==
null && $total_count < 2)
60 return $this->view_control_factory->group([
61 $this->view_control_factory->nullControl(),
62 $this->view_control_factory->nullControl()
67 foreach ($sortable_visible_cols as $col_id => $col) {
69 $order_asc = $this->data_factory->order($col_id,
Order::ASC);
70 $order_desc = $this->data_factory->order($col_id,
Order::DESC);
72 $labels = $col->getOrderingLabels();
73 $sort_options[$labels[0]] = $order_asc;
74 $sort_options[$labels[1]] = $order_desc;
77 $value = $this->
getOrder()->join(
'', fn($ret, $key, $value) => [$key, $value]);
78 return $this->view_control_factory->sortation($sort_options)
85 $clone->order = $order;
Both the subject and the direction need to be specified when expressing an order.
A Column describes the form of presentation for a certain aspect of data, i.e.
trait TableViewControlOrdering
getViewControlOrdering(int|null $total_count)
initViewControlOrdering()