ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
TableRetrieval.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Repository\Table;
22 
27 
28 class TableRetrieval implements Table\DataRetrieval
29 {
30  public function __construct(
31  protected RetrievalInterface $retrieval,
32  protected array $actions,
33  protected ?\Closure $active_action_closure,
34  protected ?\Closure $row_transformer
35  ) {
36  }
37 
38  public function getRows(
39  Table\DataRowBuilder $row_builder,
40  array $visible_column_ids,
41  Range $range,
42  Order $order,
43  ?array $filter_data,
44  ?array $additional_parameters
45  ): \Generator {
46  foreach ($this->retrieval->getData(
47  $visible_column_ids,
48  $range,
49  $order,
50  $filter_data ?? [],
51  $additional_parameters ?? []
52  ) as $data) {
53  if ($this->row_transformer) {
54  $table_data = ($this->row_transformer)($data);
55  } else {
56  $table_data = $data;
57  }
58  $row = $row_builder->buildDataRow((string) $data["id"], $table_data);
59  if ($this->active_action_closure) {
60  foreach ($this->actions as $action) {
61  if (!($this->active_action_closure)($action, $data)) {
62  $row = $row->withDisabledAction($action);
63  }
64  }
65  }
66  yield $row;
67  }
68  }
69 
70  public function getTotalRowCount(
71  ?array $filter_data,
72  ?array $additional_parameters
73  ): ?int {
74  return $this->retrieval->count(
75  $filter_data ?? [],
76  $additional_parameters ?? []
77  );
78  }
79 }
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
__construct(protected RetrievalInterface $retrieval, protected array $actions, protected ?\Closure $active_action_closure, protected ?\Closure $row_transformer)
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:28
getRows(Table\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28