ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
SmoothTableConfig.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\LegalDocuments;
22 
23 use ilTable2GUI;
24 use Closure;
25 
30 {
32  private array $later = [];
33 
34  public function __construct(private readonly ilTable2GUI $target)
35  {
36  }
37 
38  public function setTitle(
39  string $a_title,
40  string $a_icon = "",
41  string $a_icon_alt = ""
42  ): void {
43  $this->target->setTitle(...func_get_args());
44  }
45 
46  public function setExternalSorting(bool $a_val): void
47  {
48  $this->target->setExternalSorting($a_val);
49  }
50 
51  public function setDefaultOrderField(string $a_defaultorderfield): void
52  {
53  $this->target->setDefaultOrderField($a_defaultorderfield);
54  }
55 
56  public function setDefaultOrderDirection(string $a_defaultorderdirection): void
57  {
58  $this->target->setDefaultOrderDirection($a_defaultorderdirection);
59  }
60 
61  public function setSelectableColumns(string ...$names): void
62  {
63  $this->target->setSelectableColumns(...$names);
64  }
65 
66  public function addMultiCommand(string $a_cmd, string $a_text): void
67  {
68  $this->later[] = fn() => $this->target->addMultiCommand($a_cmd, $a_text);
69  }
70 
71  public function addCommandButton(
72  string $a_cmd,
73  string $a_text,
74  string $a_onclick = '',
75  string $a_id = "",
76  string $a_class = ""
77  ): void {
78  $args = func_get_args();
79  $this->later[] = fn() => $this->target->addCommandButton(...$args);
80  }
81 
82  public function asFilter(string $reset_command): TableFilter
83  {
84  $filter = new SmoothTableFilter($this->target, $reset_command);
85  $this->later[] = $filter->flush(...);
86  return $filter;
87  }
88 
89  public function flush(): void
90  {
91  array_map(fn($proc) => $proc(), $this->later);
92  $this->later = [];
93  }
94 }
This class takes care of the order in which the methods must be called.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
__construct(private readonly ilTable2GUI $target)
setDefaultOrderField(string $a_defaultorderfield)
addMultiCommand(string $a_cmd, string $a_text)
setDefaultOrderDirection(string $a_defaultorderdirection)