ILIAS  release_8 Revision v8.24
DataRow.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\UI\Implementation\Component\ComponentHelper;
26
27class DataRow implements T\DataRow
28{
29 use ComponentHelper;
30
34 protected array $disabled_actions = [];
35
38 protected array $columns;
39 protected array $actions;
40 protected string $id;
41 protected array $record;
42
51 public function __construct(
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}
string()
Contains constraints for string.
Definition: Factory.php:86
bool()
Get a kind transformation to a bool.
Definition: Group.php:159
__construct(bool $table_has_singleactions, bool $table_has_multiactions, array $columns, array $actions, string $id, array $record)
The records's key is the column-id of the table.
Definition: DataRow.php:51
withDisabledAction(string $action_id, bool $disable=true)
Definition: DataRow.php:72
ilDclBaseRecordModel $record
clone(ilDclStandardField $original_record)
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...