ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Contact\TableRows Class Reference

@phpstan-import-type RelationRecord from \ILIAS\Contact\BuddySystem\Tables\RelationsTable More...

+ Inheritance diagram for ILIAS\Contact\TableRows:
+ Collaboration diagram for ILIAS\Contact\TableRows:

Public Member Functions

 __construct (private readonly array $records, private readonly array $sigle_actions, private readonly Closure $link_to_profile)
 
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Detailed Description

@phpstan-import-type RelationRecord from \ILIAS\Contact\BuddySystem\Tables\RelationsTable

Definition at line 33 of file TableRows.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Contact\TableRows::__construct ( private readonly array  $records,
private readonly array  $sigle_actions,
private readonly Closure  $link_to_profile 
)
Parameters
list<RelationRecord>$records
list<string>$sigle_actions
Closure(int,string)string $link_to_profile

Definition at line 40 of file TableRows.php.

44 {
45 }

Member Function Documentation

◆ getRows()

ILIAS\Contact\TableRows::getRows ( DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 47 of file TableRows.php.

55 : Generator {
56 [$order_field, $order_direction] = $order->join(
57 [],
58 fn($ret, $key, $value) => [$key, $value]
59 );
60
61 $records = $this->records;
62
63 $times = $order_direction === 'ASC' ? 1 : -1;
64 usort(
65 $records,
66 static fn(array $a, array $b): int => $times * strcasecmp(
67 $a[$order_field],
68 $b[$order_field]
69 )
70 );
71
72 if ($range) {
73 $records = \array_slice($records, $range->getStart(), $range->getLength());
74 }
75
76 foreach ($records as $row) {
77 $row['public_name'] = ($this->link_to_profile)($row['user_id'], $row['public_name']);
78 $row['login'] = ($this->link_to_profile)($row['user_id'], $row['login']);
79
80 $transitions = array_map(
81 static fn($s): string => $row['state'] . '->' . $s,
82 $row['target_states']
83 );
84
85 $data_row = $row_builder->buildDataRow((string) $row['user_id'], $row);
86 foreach ($this->sigle_actions as $action) {
87 if (!\in_array($action, $transitions, true)) {
88 $data_row = $data_row->withDisabledAction($action);
89 }
90 }
91
92 yield $data_row;
93 }
94 }
join($init, callable $fn)
Definition: Order.php:75
buildDataRow(string $id, array $record)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

◆ getTotalRowCount()

ILIAS\Contact\TableRows::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 96 of file TableRows.php.

100 : ?int {
101 return \count($this->records);
102 }

The documentation for this class was generated from the following file: