getAttributeOrders() public method

Returns the currently requested sort information.
public getAttributeOrders ( boolean $recalculate = false ) : array
$recalculate boolean whether to recalculate the sort directions
return array sort directions indexed by attribute names. Sort direction can be either `SORT_ASC` for ascending order or `SORT_DESC` for descending order.
Esempio n. 1
0
 public function testGetAttributeOrders()
 {
     $sort = new Sort(['attributes' => ['age', 'name' => ['asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC], 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC]]], 'params' => ['sort' => 'age,-name'], 'enableMultiSort' => true]);
     $orders = $sort->getAttributeOrders();
     $this->assertEquals(2, count($orders));
     $this->assertEquals(SORT_ASC, $orders['age']);
     $this->assertEquals(SORT_DESC, $orders['name']);
     $sort->enableMultiSort = false;
     $orders = $sort->getAttributeOrders(true);
     $this->assertEquals(1, count($orders));
     $this->assertEquals(SORT_ASC, $orders['age']);
 }