ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DataRow.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\UI\Implementation\Component\ComponentHelper;
26
27class DataRow implements T\DataRow
28{
29 use ComponentHelper;
30
34 protected array $disabled_actions = [];
35
44 public function __construct(
45 protected bool $table_has_singleactions,
46 protected bool $table_has_multiactions,
47 protected array $columns,
48 protected array $actions,
49 protected string $id,
50 protected array $record
51 ) {
52 }
53
54 public function getId(): string
55 {
56 return $this->id;
57 }
58
59 public function withDisabledAction(string $action_id, bool $disable = true): static
60 {
61 if (!$disable) {
62 return $this;
63 }
64 $clone = clone $this;
65 $clone->disabled_actions[$action_id] = true;
66 return $clone;
67 }
68
69 public function getColumns(): array
70 {
71 return $this->columns;
72 }
73
74 public function tableHasSingleActions(): bool
75 {
76 return $this->table_has_singleactions;
77 }
78 public function tableHasMultiActions(): bool
79 {
81 }
82
83 public function getActions(): array
84 {
85 return array_filter(
86 $this->actions,
87 function (string $id): bool {
88 return !array_key_exists($id, $this->disabled_actions);
89 },
90 ARRAY_FILTER_USE_KEY
91 );
92 }
93
94 public function getCellContent(string $col_id): string|Component
95 {
96 if (!array_key_exists($col_id, $this->record)) {
97 return '';
98 }
99 return $this->columns[$col_id]->format($this->record[$col_id]);
100 }
101}
bool()
Get a kind transformation to a bool.
Definition: Group.php:159
__construct(protected bool $table_has_singleactions, protected bool $table_has_multiactions, protected array $columns, protected array $actions, protected string $id, protected array $record)
The records's key is the column-id of the table.
Definition: DataRow.php:44
withDisabledAction(string $action_id, bool $disable=true)
Definition: DataRow.php:59
clone(int $target_parent_obj_id)
A component is the most general form of an entity in the UI.
Definition: Component.php:28