ILIAS  release_8 Revision v8.23
DataRow.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
27 class DataRow implements T\DataRow
28 {
29  use ComponentHelper;
30 
34  protected array $disabled_actions = [];
35 
36  protected bool $table_has_singleactions;
37  protected bool $table_has_multiactions;
38  protected array $columns;
39  protected array $actions;
40  protected string $id;
41  protected array $record;
42 
51  public function __construct(
52  bool $table_has_singleactions,
53  bool $table_has_multiactions,
54  array $columns,
55  array $actions,
56  string $id,
57  array $record
58  ) {
59  $this->table_has_singleactions = $table_has_singleactions;
60  $this->table_has_multiactions = $table_has_multiactions;
61  $this->columns = $columns;
62  $this->actions = $actions;
63  $this->id = $id;
64  $this->record = $record;
65  }
66 
67  public function getId(): string
68  {
69  return $this->id;
70  }
71 
72  public function withDisabledAction(string $action_id, bool $disable = true): T\DataRow
73  {
74  if (!$disable) {
75  return $this;
76  }
77  $clone = clone $this;
78  $clone->disabled_actions[$action_id] = true;
79  return $clone;
80  }
81 
82  public function getColumns(): array
83  {
84  return $this->columns;
85  }
86 
87  public function tableHasSingleActions(): bool
88  {
90  }
91  public function tableHasMultiActions(): bool
92  {
94  }
95 
96  public function getActions(): array
97  {
98  return array_filter(
99  $this->actions,
100  function (string $id): bool {
101  return !array_key_exists($id, $this->disabled_actions);
102  },
103  ARRAY_FILTER_USE_KEY
104  );
105  }
106 
107  public function getCellContent(string $col_id)
108  {
109  if (!array_key_exists($col_id, $this->record)) {
110  return '';
111  }
112  return $this->columns[$col_id]->format($this->record[$col_id]);
113  }
114 }
__construct(bool $table_has_singleactions, bool $table_has_multiactions, array $columns, array $actions, string $id, array $record)
The records&#39;s key is the column-id of the table.
Definition: DataRow.php:51
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withDisabledAction(string $action_id, bool $disable=true)
Refer to an Action by its id and disable it for this row/record only.
Definition: DataRow.php:72