ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 
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  {
80  return $this->table_has_multiactions;
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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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:59
__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&#39;s key is the column-id of the table.
Definition: DataRow.php:44