ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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(new Order('position', 'ASC'));
46 foreach ($records as $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(
51 'custom'
52 );
53 yield $row_builder->buildOrderingRow($row_id, $record)
54 ->withDisabledAction('translate', !$this->has_write_access);
55 }
56 }
57
58 protected function getRecords(Order $order): array
59 {
60 $records = $this->facade->fieldFactory()->filterAllFieldsForTypeAsArray($this->facade->type());
61 [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value): array => [$key, $value]);
62 usort($records, fn($a, $b): int => $a[$order_field] <=> $b[$order_field]);
63 if ($order_direction === 'DESC') {
64 return array_reverse($records);
65 }
66 return $records;
67 }
68
69 public function getTotalRowCount(
70 ?array $filter_data,
71 ?array $additional_parameters
72 ): ?int {
73 return count($this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId()));
74 }
75}
__construct(protected \ilBiblAdminFactoryFacadeInterface $facade, private bool $has_write_access)
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...
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
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...
buildOrderingRow(string $id, array $record)
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