ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
PersonalSettingsTable.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
24use ILIAS\Data\Factory as DataFactory;
33use ILIAS\UI\Component\Table\Data as DataTable;
34use ILIAS\UI\Factory as UIFactory;
36
38{
39 private const string ID = 'pst';
40
41 public function __construct(
42 private readonly Language $lng,
43 private readonly UIFactory $ui_factory,
44 private readonly DataFactory $data_factory,
45 private readonly \ilObjUser $user,
46 private readonly RequestDataCollector $test_request,
47 private readonly PersonalSettingsTableActions $table_actions,
48 private readonly URLBuilder $url_builder,
49 private readonly PersonalSettingsRepository $repository,
50 ) {
51 }
52
53 public function perform(): ?Modal
54 {
55 return $this->table_actions->perform(...$this->acquireParameters());
56 }
57
58 private function acquireParameters(): array
59 {
60 return $this->url_builder->acquireParameters(
61 [self::ID],
65 );
66 }
67
71 private function getColumns(): array
72 {
73 $column_factory = $this->ui_factory->table()->column();
74
75 return [
76 'name' => $column_factory->text($this->lng->txt('personal_settings_name')),
77 'description' => $column_factory->text($this->lng->txt('personal_settings_description'))->withIsSortable(false),
78 'tstamp' => $column_factory->date($this->lng->txt('personal_settings_timestamp'), $this->user->getDateTimeFormat()),
79 'author' => $column_factory->text($this->lng->txt('personal_settings_author'))
80 ];
81 }
82
83 public function getComponent(): DataTable
84 {
85 return $this->ui_factory->table()
86 ->data($this, $this->lng->txt('personal_settings_templates_available'), $this->getColumns())
87 ->withRequest($this->test_request->getRequest())
88 ->withActions($this->table_actions->getActions(...$this->acquireParameters()))
89 ->withOrder(new Order('tstamp', Order::DESC))
90 ->withId(self::ID);
91 }
92
93 public function getRows(
94 DataRowBuilder $row_builder,
95 array $visible_column_ids,
97 Order $order,
98 mixed $additional_viewcontrol_data,
99 mixed $filter_data,
100 mixed $additional_parameters
101 ): Generator {
102 foreach ($this->repository->getForUser($range, $order) as $template) {
103 $row = [
104 'name' => $template->getName(),
105 'tstamp' => $template->getCreatedAt(),
106 'description' => $template->getDescription(),
107 'author' => $template->getAuthor(),
108 ];
109
110 yield $row_builder->buildDataRow((string) $template->getId(), $row);
111 }
112 }
113
114 public function getTotalRowCount(
115 mixed $additional_viewcontrol_data,
116 mixed $filter_data,
117 mixed $additional_parameters
118 ): ?int {
119 return $this->repository->countForUser();
120 }
121}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
const DESC
Definition: Order.php:31
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
__construct(private readonly Language $lng, private readonly UIFactory $ui_factory, private readonly DataFactory $data_factory, private readonly \ilObjUser $user, private readonly RequestDataCollector $test_request, private readonly PersonalSettingsTableActions $table_actions, private readonly URLBuilder $url_builder, private readonly PersonalSettingsRepository $repository,)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
User class.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes commonalities between the different modals.
Definition: Modal.php:35
A Column describes the form of presentation for a certain aspect of data, i.e.
Definition: Column.php:28
buildDataRow(string $id, array $record)
This describes a Data Table.
Definition: Data.php:33
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31