ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
trait.RetrievalBase.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Repository;
22 
25 
26 trait RetrievalBase
27 {
28  protected function applyOrder(array $data, ?Order $order = null): array
29  {
30  if ($order !== null) {
31  $order_field = array_keys($order->get())[0];
32  $order_direction = $order->get()[$order_field];
33 
34  if (count(array_column($data, $order_field)) === 0) {
35  return $data;
36  }
37  array_multisort(
38  array_column($data, $order_field),
39  $order_direction === 'ASC' ? SORT_ASC : SORT_DESC,
40  $this->isFieldNumeric($order_field) ? SORT_NUMERIC : SORT_STRING,
41  $data
42  );
43  }
44  return $data;
45  }
46 
47  protected function applyRange(array $data, ?Range $range = null): array
48  {
49  if ($range !== null) {
50  $offset = $range->getStart();
51  $limit = $range->getLength();
52  $data = array_slice($data, $offset, $limit);
53  }
54  return $data;
55  }
56 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null