ILIAS  trunk Revision v12.0_alpha-1613-gae4c99ebb18
ILIAS\BookingManager\Participant\Table\ParticipantTable Class Reference
+ Inheritance diagram for ILIAS\BookingManager\Participant\Table\ParticipantTable:
+ Collaboration diagram for ILIAS\BookingManager\Participant\Table\ParticipantTable:

Public Member Functions

 __construct (private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly ilLanguage $lng, private readonly HttpService $http, private readonly ilUIService $ui_service, private readonly ilCtrlInterface $ctrl, private readonly ilGlobalTemplateInterface $tpl, private readonly Refinery $refinery, private readonly AccessManager $access, private readonly ParticipantRepository $participant_repository, private readonly int $ref_id, private readonly int $pool_id,)
 @phpstan-type ParticipantRecord array{user_id: int, name: string, object_title: array<string>, obj_count: int, object_ids: array<int>} More...
 
 getTableId ()
 
 getComponents (URLBuilder $url_builder)
 
 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 records available. More...
 
 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.g. More...
 
- Public Member Functions inherited from ILIAS\BookingManager\Common\Table\Table
 getTableId ()
 
 execute (URLBuilder $url_builder)
 
 getComponents (URLBuilder $url_builder)
 
 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.g. More...
 
 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 records available. More...
 

Data Fields

const ID = 'bksp'
 
const ROW_ID_PARAMETER = 'participant_id'
 
const ACTION_PARAMETER = 'action'
 
const ACTION_TYPE_PARAMETER = 'action_type'
 

Protected Member Functions

 sortRecords (Order $order, array $records)
 
 limitRecords (Range $range, array $records)
 
 acquireParameters (URLBuilder $url_builder)
 
 getTableActions ()
 

Private Member Functions

 getColumns ()
 
 loadRecords (?array $filter_data)
 
 getFilterComponent (string $action)
 

Detailed Description

Definition at line 49 of file ParticipantTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\BookingManager\Participant\Table\ParticipantTable::__construct ( private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly ilLanguage  $lng,
private readonly HttpService  $http,
private readonly ilUIService  $ui_service,
private readonly ilCtrlInterface  $ctrl,
private readonly ilGlobalTemplateInterface  $tpl,
private readonly Refinery  $refinery,
private readonly AccessManager  $access,
private readonly ParticipantRepository  $participant_repository,
private readonly int  $ref_id,
private readonly int  $pool_id 
)

@phpstan-type ParticipantRecord array{user_id: int, name: string, object_title: array<string>, obj_count: int, object_ids: array<int>}

Definition at line 64 of file ParticipantTable.php.

77 {
78 }

Member Function Documentation

◆ acquireParameters()

ILIAS\BookingManager\Participant\Table\ParticipantTable::acquireParameters ( URLBuilder  $url_builder)
protected
Returns
array{URLBuilder, URLBuilderToken, URLBuilderToken, URLBuilderToken}

Definition at line 240 of file ParticipantTable.php.

240 : array
241 {
242 return $url_builder->acquireParameters(
243 [self::ID],
244 self::ROW_ID_PARAMETER,
245 self::ACTION_PARAMETER,
246 self::ACTION_TYPE_PARAMETER
247 );
248 }
acquireParameters(array $namespace, string ... $names)
Definition: URLBuilder.php:138

References ILIAS\UI\URLBuilder\acquireParameters().

Referenced by ILIAS\BookingManager\Participant\Table\ParticipantTable\getComponents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumns()

ILIAS\BookingManager\Participant\Table\ParticipantTable::getColumns ( )
private
Returns
array<string, Column>

Definition at line 139 of file ParticipantTable.php.

139 : array
140 {
141 $column_factory = $this->ui_factory->table()->column();
142 return [
143 'name' => $column_factory->text($this->lng->txt('name'))->withIsSortable(true),
144 'bookable_item' => $column_factory->text($this->lng->txt('book_bobj'))->withIsSortable(false),
145 ];
146 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponents()

ILIAS\BookingManager\Participant\Table\ParticipantTable::getComponents ( URLBuilder  $url_builder)
Returns
array<Component>

Implements ILIAS\BookingManager\Common\Table\Table.

Definition at line 88 of file ParticipantTable.php.

88 : array
89 {
90 $filter = $this->getFilterComponent($url_builder->buildURI()->__toString());
91
92 $table = $this->ui_factory->table()->data($this, $this->lng->txt('participants'), $this->getColumns())
93 ->withActions($this->getTableActions()->getEnabledActions(...$this->acquireParameters($url_builder)))
94 ->withRequest($this->http->getRequest())
95 ->withId($this->getTableId())
96 ->withFilter($this->ui_service->filter()->getData($filter));
97
98 return [$filter, $table];
99 }
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
Definition: URLBuilder.php:214
static http()
Fetches the global http state from ILIAS.

References ILIAS\BookingManager\Participant\Table\ParticipantTable\acquireParameters(), ILIAS\UI\URLBuilder\buildURI(), ILIAS\BookingManager\Participant\Table\ParticipantTable\getFilterComponent(), ILIAS\BookingManager\Participant\Table\ParticipantTable\getTableActions(), ILIAS\BookingManager\Participant\Table\ParticipantTable\getTableId(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getFilterComponent()

ILIAS\BookingManager\Participant\Table\ParticipantTable::getFilterComponent ( string  $action)
private

Definition at line 205 of file ParticipantTable.php.

205 : FilterComponent
206 {
207 $bookable_items = [];
208 foreach (ilBookingObject::getList($this->pool_id) as $item) {
209 $bookable_items[$item['booking_object_id']] = $item['title'];
210 }
211
212 $field_factory = $this->ui_factory->input()->field();
213 $filter_inputs = [
214 'bookable_item_id' => $field_factory->select(
215 $this->lng->txt('book_bobj'),
216 array_replace(['-1' => $this->lng->txt('book_no_objects')], $bookable_items)
217 ),
218 'bookable_item_title' => $field_factory->text(
219 "{$this->lng->txt('book_bobj')} {$this->lng->txt('title')}/{$this->lng->txt('description')}"
220 ),
221 'participant_id' => $field_factory->select(
222 $this->lng->txt('book_participant'),
224 ),
225 ];
226
227 return $this->ui_service->filter()->standard(
228 "participant_filter_{$this->pool_id}",
229 $action,
230 $filter_inputs,
231 array_fill(0, count($filter_inputs), true),
232 true,
233 true
234 );
235 }
static getList(int $a_pool_id, ?string $a_title=null)
Get list of booking objects.
static getUserFilter(int $a_pool_id)
Get user data from db for an specific pool id.

References ilBookingObject\getList(), ilBookingParticipant\getUserFilter(), and ILIAS\Repository\lng().

Referenced by ILIAS\BookingManager\Participant\Table\ParticipantTable\getComponents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

ILIAS\Test\Participants\ParticipantTable::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.g.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 109 of file ParticipantTable.php.

117 : Generator {
118 $records = $this->limitRecords($range, $this->sortRecords($order, $this->loadRecords($filter_data)));
119
120 foreach ($records as $record) {
121 yield $this->getTableActions()->onDataRow(
122 $row_builder->buildDataRow(
123 (string) $record['user_id'],
124 [
125 'name' => $record['name'] ?? '',
126 'bookable_item' => $this->ui_renderer->render(
127 $this->ui_factory->listing()->unordered($record['object_title'] ?? [])
128 ),
129 ]
130 ),
131 $record
132 );
133 }
134 }
buildDataRow(string $id, array $record)

References ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow(), and ILIAS\BookingManager\Common\Table\getTableActions().

+ Here is the call graph for this function:

◆ getTableActions()

ILIAS\BookingManager\Participant\Table\ParticipantTable::getTableActions ( )
protected

Definition at line 250 of file ParticipantTable.php.

250 : TableActions
251 {
252 return (new ParticipantTableActionsFactory(
253 $this->ctrl,
254 $this->lng,
255 $this->tpl,
256 $this->ui_factory,
257 $this->ui_renderer,
258 $this->refinery,
259 $this->http,
260 $this->access,
261 $this->participant_repository,
262 $this->ref_id,
263 $this->pool_id,
264 ))->getTableActions();
265 }

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by ILIAS\BookingManager\Participant\Table\ParticipantTable\getComponents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableId()

ILIAS\BookingManager\Participant\Table\ParticipantTable::getTableId ( )

◆ getTotalRowCount()

ILIAS\BookingManager\Participant\Table\ParticipantTable::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 records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 101 of file ParticipantTable.php.

105 : ?int {
106 return count($this->loadRecords($filter_data));
107 }

◆ limitRecords()

ILIAS\BookingManager\Participant\Table\ParticipantTable::limitRecords ( Range  $range,
array  $records 
)
protected

Definition at line 200 of file ParticipantTable.php.

200 : array
201 {
202 return array_slice($records, $range->getStart(), $range->getLength());
203 }

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

+ Here is the call graph for this function:

◆ loadRecords()

ILIAS\BookingManager\Participant\Table\ParticipantTable::loadRecords ( ?array  $filter_data)
private

Definition at line 148 of file ParticipantTable.php.

148 : array
149 {
150 $filter = [];
151
152 if (isset($filter_data['bookable_item_id']) && $filter_data['bookable_item_id'] !== '') {
153 $filter['object'] = (int) $filter_data['bookable_item_id'];
154 }
155
156 if (isset($filter_data['bookable_item_title']) && $filter_data['bookable_item_title'] !== '') {
157 $filter['title'] = (string) $filter_data['bookable_item_title'];
158 }
159
160 if (isset($filter_data['participant_id']) && $filter_data['participant_id'] !== '') {
161 $filter['user_id'] = (int) $filter_data['participant_id'];
162 }
163
164 $filter_object = isset($filter['object']) ? (int) $filter['object'] : null;
165 if ($filter_object === -1) {
166 return array_filter(
167 ilBookingParticipant::getList($this->pool_id, $filter),
168 static fn(array $item): bool => ($item['obj_count'] ?? 0) === 0
169 );
170 }
171
172 return ilBookingParticipant::getList($this->pool_id, $filter, $filter_object);
173 }
static getList(int $a_booking_pool, ?array $a_filter=null, ?int $a_object_id=null)

References ilBookingParticipant\getList(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ sortRecords()

ILIAS\BookingManager\Participant\Table\ParticipantTable::sortRecords ( Order  $order,
array  $records 
)
protected

Definition at line 175 of file ParticipantTable.php.

175 : array
176 {
177 $order_data = $order->get();
178 if ($order_data === []) {
179 return $records;
180 }
181
182 foreach ($order_data as $key => $value) {
183 $order_direction = $value === Order::DESC ? -1 : 1;
184 $callable = match ($key) {
185 'name' => static fn(array $a, array $b): int => strcmp($a['name'], $b['name']) * $order_direction,
186 'bookable_item' => static fn(array $a, array $b): int => strcmp($a['bookable_item'], $b['bookable_item']) * $order_direction,
187 default => null,
188 };
189
190 if ($callable === null) {
191 continue;
192 }
193
194 usort($records, $callable);
195 }
196
197 return $records;
198 }
const DESC
Definition: Order.php:31
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, and ILIAS\Data\Order\get().

+ Here is the call graph for this function:

Field Documentation

◆ ACTION_PARAMETER

const ILIAS\BookingManager\Participant\Table\ParticipantTable::ACTION_PARAMETER = 'action'

Definition at line 57 of file ParticipantTable.php.

◆ ACTION_TYPE_PARAMETER

const ILIAS\BookingManager\Participant\Table\ParticipantTable::ACTION_TYPE_PARAMETER = 'action_type'

Definition at line 59 of file ParticipantTable.php.

◆ ID

const ILIAS\BookingManager\Participant\Table\ParticipantTable::ID = 'bksp'

◆ ROW_ID_PARAMETER

const ILIAS\BookingManager\Participant\Table\ParticipantTable::ROW_ID_PARAMETER = 'participant_id'

Definition at line 55 of file ParticipantTable.php.


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