ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ILIAS\LegalDocuments\Table\DocumentTable Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\Table\DocumentTable:
+ Collaboration diagram for ILIAS\LegalDocuments\Table\DocumentTable:

Public Member Functions

 __construct (private readonly Closure $criterion_as_component, private readonly DocumentRepository $repository, private readonly UI $ui, private readonly DocumentModal $modal, ?Closure $create=null, ?Closure $format_date=null)
 
 columns ()
 
 config (TableConfig $config)
 
 rows (TableSelection $select)
 
 mapSelection (Closure $proc, TableSelection $select)
 
 select (TableSelection $select)
 
 row (Document $document, int $sorting)
 
 showCriteria (Document $document, Closure $proc)
 
 showCriterion (Criterion $criterion)
 
 criterionName (Criterion $criterion)
 
 orderInputGui (Document $document, int $sorting)
 
 step ()
 
 ui ()
 
 name ()
 

Private Attributes

readonly Closure $create
 
readonly Closure $format_date
 

Detailed Description

Definition at line 38 of file DocumentTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\Table\DocumentTable::__construct ( private readonly Closure  $criterion_as_component,
private readonly DocumentRepository  $repository,
private readonly UI  $ui,
private readonly DocumentModal  $modal,
?Closure  $create = null,
?Closure  $format_date = null 
)
Parameters
Closure(CriterionContent)Component $criterion_as_component
null|Closure(class-string,...$constructor_args): object<class-string> $create
Closure(DateTimeImmutable)string $format_date

Definition at line 50 of file DocumentTable.php.

References ilDatePresentation\formatDate(), and IL_CAL_UNIX.

57  {
58  $this->create = $create ?? fn($class, ...$args) => new $class(...$args);
59  $this->format_date = $format_date ?? fn(DateTimeImmutable $date) => ilDatePresentation::formatDate(new ilDateTime($date->getTimestamp(), IL_CAL_UNIX));
60  }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ilObjUser $user=null,)
const IL_CAL_UNIX
+ Here is the call graph for this function:

Member Function Documentation

◆ columns()

ILIAS\LegalDocuments\Table\DocumentTable::columns ( )
Returns
array<string, list<string>>

Implements ILIAS\LegalDocuments\Table.

Definition at line 62 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\ui().

62  : array
63  {
64  return [
65  'order' => [$this->ui->txt('tbl_docs_head_sorting'), '', '5%'],
66  'title' => [$this->ui->txt('tbl_docs_head_title'), '', '25%'],
67  'created' => [$this->ui->txt('tbl_docs_head_created')],
68  'change' => [$this->ui->txt('tbl_docs_head_last_change')],
69  'criteria' => [$this->ui->txt('tbl_docs_head_criteria')],
70  ];
71  }
+ Here is the call graph for this function:

◆ config()

ILIAS\LegalDocuments\Table\DocumentTable::config ( TableConfig  $config)

Implements ILIAS\LegalDocuments\Table.

Definition at line 73 of file DocumentTable.php.

References ILIAS\LegalDocuments\TableConfig\setSelectableColumns(), ILIAS\LegalDocuments\TableConfig\setTitle(), and ILIAS\LegalDocuments\Table\DocumentTable\ui().

73  : void
74  {
75  $config->setTitle($this->ui->txt('tbl_docs_title'));
76  $config->setSelectableColumns('created', 'change');
77  }
+ Here is the call graph for this function:

◆ criterionName()

ILIAS\LegalDocuments\Table\DocumentTable::criterionName ( Criterion  $criterion)

Definition at line 134 of file DocumentTable.php.

References ILIAS\LegalDocuments\Value\Criterion\content().

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\showCriterion().

134  : Component
135  {
136  return ($this->criterion_as_component)($criterion->content());
137  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapSelection()

ILIAS\LegalDocuments\Table\DocumentTable::mapSelection ( Closure  $proc,
TableSelection  $select 
)

Definition at line 84 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\select(), and ILIAS\LegalDocuments\Table\DocumentTable\step().

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\rows().

84  : array
85  {
86  $step = $this->step();
87  return array_map(fn($x) => $proc($x, $step()), $this->select($select));
88  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ name()

ILIAS\LegalDocuments\Table\DocumentTable::name ( )

Implements ILIAS\LegalDocuments\Table.

Definition at line 164 of file DocumentTable.php.

164  : string
165  {
166  return self::class;
167  }

◆ orderInputGui()

ILIAS\LegalDocuments\Table\DocumentTable::orderInputGui ( Document  $document,
int  $sorting 
)

Definition at line 139 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\$create, and ILIAS\LegalDocuments\Value\Document\id().

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\row().

140  {
141  $input = ($this->create)(ilNumberInputGUI::class, '', 'order[' . $document->id() . ']');
142  $input->setValue((string) $sorting);
143  $input->setMaxLength(4);
144  $input->setSize(2);
145  $input->setDisabled(true);
146 
147  return $input;
148  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ row()

ILIAS\LegalDocuments\Table\DocumentTable::row ( Document  $document,
int  $sorting 
)

Definition at line 95 of file DocumentTable.php.

References ILIAS\LegalDocuments\Value\Document\content(), ILIAS\LegalDocuments\Value\Document\meta(), ILIAS\Repository\modal(), ILIAS\LegalDocuments\Table\DocumentTable\orderInputGui(), ILIAS\LegalDocuments\Table\DocumentTable\showCriteria(), and ILIAS\LegalDocuments\Table\DocumentTable\showCriterion().

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\rows().

95  : array
96  {
97  $render_order = $this->orderInputGui($document, $sorting);
98 
99  return [
100  'order' => fn() => $render_order->render(),
101  'title' => $this->modal->create($document->content()),
102  'created' => ($this->format_date)($document->meta()->creation()->time()),
103  'change' => ($this->format_date)($document->meta()->lastModification()->time()),
104  'criteria' => $this->showCriteria($document, $this->showCriterion(...)),
105  ];
106  }
showCriteria(Document $document, Closure $proc)
orderInputGui(Document $document, int $sorting)
modal(string $title="", string $cancel_label="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rows()

ILIAS\LegalDocuments\Table\DocumentTable::rows ( TableSelection  $select)
Returns
list<array<string, string|Closure(): string>>

Implements ILIAS\LegalDocuments\Table.

Definition at line 79 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\mapSelection(), and ILIAS\LegalDocuments\Table\DocumentTable\row().

79  : array
80  {
81  return $this->mapSelection($this->row(...), $select);
82  }
row(Document $document, int $sorting)
mapSelection(Closure $proc, TableSelection $select)
+ Here is the call graph for this function:

◆ select()

ILIAS\LegalDocuments\Table\DocumentTable::select ( TableSelection  $select)

Definition at line 90 of file DocumentTable.php.

References ILIAS\UI\examples\Deck\repository().

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\mapSelection().

90  : array
91  {
92  return $this->repository->all();
93  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showCriteria()

ILIAS\LegalDocuments\Table\DocumentTable::showCriteria ( Document  $document,
Closure  $proc 
)
Parameters
Closure(Criterion)list<Component> $proc
Returns
string|list<Component>

Definition at line 112 of file DocumentTable.php.

References ILIAS\LegalDocuments\Value\Document\criteria(), and ILIAS\LegalDocuments\Table\DocumentTable\ui().

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\row().

113  {
114  if ([] === $document->criteria()) {
115  return $this->ui->txt('tbl_docs_cell_not_criterion');
116  }
117  return array_merge(...array_map(
118  $proc,
119  $document->criteria()
120  ));
121  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showCriterion()

ILIAS\LegalDocuments\Table\DocumentTable::showCriterion ( Criterion  $criterion)
Returns
list<Component>

Definition at line 126 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\criterionName(), and ILIAS\LegalDocuments\Table\DocumentTable\ui().

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\row().

126  : array
127  {
128  return [
129  $this->criterionName($criterion),
130  $this->ui->create()->legacy('<br/>'),
131  ];
132  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ step()

ILIAS\LegalDocuments\Table\DocumentTable::step ( )

Definition at line 150 of file DocumentTable.php.

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\mapSelection().

150  : Closure
151  {
152  $step = 0;
153  return static function () use (&$step): int {
154  $step += 10;
155  return $step;
156  };
157  }
+ Here is the caller graph for this function:

◆ ui()

ILIAS\LegalDocuments\Table\DocumentTable::ui ( )

Field Documentation

◆ $create

readonly Closure ILIAS\LegalDocuments\Table\DocumentTable::$create
private

◆ $format_date

readonly Closure ILIAS\LegalDocuments\Table\DocumentTable::$format_date
private

Definition at line 43 of file DocumentTable.php.


The documentation for this class was generated from the following file: