ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilDclFormulaRecordQueryObject.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  public function applyCustomSorting(
24  ilDclBaseFieldModel $field,
25  array $all_records,
26  string $direction = 'asc'
27  ): array {
28  $sort_array = [];
29  foreach ($all_records as $id) {
30  $formula_field = ilDclCache::getRecordFieldCache(new ilDclBaseRecordModel($id), $field);
31  $sort_array[$id] = $formula_field->getValue();
32  }
33  switch (strtolower($direction)) {
34  case 'asc':
35  asort($sort_array);
36  break;
37  case 'desc':
38  arsort($sort_array);
39  break;
40  }
41 
42  return array_keys($sort_array);
43  }
44 }
applyCustomSorting(ilDclBaseFieldModel $field, array $all_records, string $direction='asc')
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getRecordFieldCache(object $record, object $field)