ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
DataRetrieval.php
Go to the documentation of this file.
1<?php
2
20
24
30{
31 private \ilLanguage $lng;
32
33 public function __construct(
34 protected \ilBiblAdminFactoryFacadeInterface $facade,
35 private bool $has_write_access
36 ) {
37 global $DIC;
38 $this->lng = $DIC['lng'];
39 }
40
41 public function getRows(
42 OrderingRowBuilder $row_builder,
43 array $visible_column_ids,
44 ): \Generator {
45 $records = $this->getRecords($order);
46 foreach ($records as $idx => $record) {
47 $row_id = (string) $record['id'];
48 $field = $this->facade->fieldFactory()->findById($record['id']);
49 $record['data_type'] = $this->facade->translationFactory()->translate($field);
50 $record['is_standard_field'] = $field->isStandardField() ? $this->lng->txt('standard') : $this->lng->txt('custom');
51 yield $row_builder->buildDataRow($row_id, $record)
52 ->withDisabledAction('translate', !$this->has_write_access);
53 }
54 }
55
56 protected function getRecords(Order $order): array
57 {
58 $records = $this->facade->fieldFactory()->filterAllFieldsForTypeAsArray($this->facade->type());
59 [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value): array => [$key, $value]);
60 usort($records, fn($a, $b): int => $a[$order_field] <=> $b[$order_field]);
61 if ($order_direction === 'DESC') {
62 return array_reverse($records);
63 }
64 return $records;
65 }
66
67 public function getTotalRowCount(
68 mixed $additional_viewcontrol_data,
69 mixed $filter_data,
70 mixed $additional_parameters
71 ): ?int {
72 return count($this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId()));
73 }
74}
__construct(protected \ilBiblAdminFactoryFacadeInterface $facade, private bool $has_write_access)
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
getRows(OrderingRowBuilder $row_builder, array $visible_column_ids,)
This is called by the (ordering-)table to retrieve rows; map data-records to rows using the $row_buil...
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
join($init, callable $fn)
Definition: Order.php:75
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
global $DIC
Definition: shib_login.php:26