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

Public Member Functions

 __construct (private readonly ilCtrlInterface $ctrl, private readonly ilLanguage $lng, private readonly ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly Refinery $refinery, private readonly AccessManager $access, private readonly HttpService $http, private readonly ScheduleManager $schedule_manager, private readonly int $ref_id,)
 
 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 = 'bksd'
 
const ROW_ID_PARAMETER = 'schedule_id'
 
const ACTION_PARAMETER = 'action'
 
const ACTION_TYPE_PARAMETER = 'action_type'
 

Protected Member Functions

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

Private Member Functions

 getColumns ()
 

Detailed Description

Definition at line 46 of file ScheduleTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\BookingManager\Schedule\Table\ScheduleTable::__construct ( private readonly ilCtrlInterface  $ctrl,
private readonly ilLanguage  $lng,
private readonly ilGlobalTemplateInterface  $tpl,
private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly Refinery  $refinery,
private readonly AccessManager  $access,
private readonly HttpService  $http,
private readonly ScheduleManager  $schedule_manager,
private readonly int  $ref_id 
)

Definition at line 58 of file ScheduleTable.php.

69 {
70 }

Member Function Documentation

◆ acquireParameters()

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

Definition at line 184 of file ScheduleTable.php.

184 : array
185 {
186 return $url_builder->acquireParameters(
187 [self::ID],
188 self::ROW_ID_PARAMETER,
189 self::ACTION_PARAMETER,
190 self::ACTION_TYPE_PARAMETER
191 );
192 }
acquireParameters(array $namespace, string ... $names)
Definition: URLBuilder.php:138

References ILIAS\UI\URLBuilder\acquireParameters().

Referenced by ILIAS\BookingManager\Schedule\Table\ScheduleTable\getComponents().

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

◆ getColumns()

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

Definition at line 161 of file ScheduleTable.php.

161 : array
162 {
163 $column_factory = $this->ui_factory->table()->column();
164 $icon_factory = $this->ui_factory->symbol()->icon();
165 return [
166 'title' => $column_factory->text($this->lng->txt('title'))->withIsSortable(true),
167 'is_used' => $column_factory->boolean(
168 $this->lng->txt('book_is_used'),
169 $icon_factory->custom(
170 ilUtil::getImagePath('standard/icon_ok.svg'),
171 $this->lng->txt('yes')
172 ),
173 $icon_factory->custom(
174 ilUtil::getImagePath('standard/icon_not_ok.svg'),
175 $this->lng->txt('no')
176 )
177 )->withIsSortable(true),
178 ];
179 }
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References ilUtil\getImagePath(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponents()

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

Implements ILIAS\BookingManager\Common\Table\Table.

Definition at line 80 of file ScheduleTable.php.

80 : array
81 {
82 return [
83 $this->ui_factory->table()->data($this, $this->lng->txt('book_schedules'), $this->getColumns())
84 ->withActions($this->getTableActions()->getEnabledActions(...$this->acquireParameters($url_builder)))
85 ->withRequest($this->http->getRequest())
86 ->withId($this->getTableId())
87 ];
88 }
static http()
Fetches the global http state from ILIAS.

References ILIAS\BookingManager\Schedule\Table\ScheduleTable\acquireParameters(), ILIAS\BookingManager\Schedule\Table\ScheduleTable\getTableActions(), ILIAS\BookingManager\Schedule\Table\ScheduleTable\getTableId(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\BookingManager\Schedule\Table\ScheduleTable::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 98 of file ScheduleTable.php.

106 : Generator {
107 $records = $this->limitRecords($range, $this->sortRecords($order, $this->loadRecords($filter_data)));
108
109 foreach ($records as $record) {
110 yield $this->getTableActions()->onDataRow(
111 $row_builder->buildDataRow(
112 (string) $record['booking_schedule_id'],
113 [
114 'title' => $record['title'] ?? '',
115 'is_used' => (bool) ($record['is_used'] ?? false),
116 ]
117 ),
118 $record
119 );
120 }
121 }
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\Schedule\Table\ScheduleTable::getTableActions ( )
protected

Definition at line 194 of file ScheduleTable.php.

194 : TableActions
195 {
196 return (new ScheduleTableActionsFactory(
197 $this->ctrl,
198 $this->lng,
199 $this->tpl,
200 $this->ui_factory,
201 $this->ui_renderer,
202 $this->refinery,
203 $this->access,
204 $this->http,
205 $this->schedule_manager,
206 $this->ref_id,
207 ))->getTableActions();
208 }

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

Referenced by ILIAS\BookingManager\Schedule\Table\ScheduleTable\getComponents().

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

◆ getTableId()

ILIAS\BookingManager\Schedule\Table\ScheduleTable::getTableId ( )

Implements ILIAS\BookingManager\Common\Table\Table.

Definition at line 72 of file ScheduleTable.php.

72 : string
73 {
74 return self::ID;
75 }

References ILIAS\BookingManager\Schedule\Table\ScheduleTable\ID.

Referenced by ILIAS\BookingManager\Schedule\Table\ScheduleTable\getComponents().

+ Here is the caller graph for this function:

◆ getTotalRowCount()

ILIAS\BookingManager\Schedule\Table\ScheduleTable::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 90 of file ScheduleTable.php.

94 : ?int {
95 return count($this->loadRecords($filter_data));
96 }

◆ limitRecords()

ILIAS\BookingManager\Schedule\Table\ScheduleTable::limitRecords ( Range  $range,
array  $records 
)
protected

Definition at line 153 of file ScheduleTable.php.

153 : array
154 {
155 return array_slice($records, $range->getStart(), $range->getLength());
156 }

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\Schedule\Table\ScheduleTable::loadRecords ( mixed  $filter_data)
protected

Definition at line 123 of file ScheduleTable.php.

123 : array
124 {
125 return $this->schedule_manager->getScheduleData();
126 }

◆ sortRecords()

ILIAS\BookingManager\Schedule\Table\ScheduleTable::sortRecords ( Order  $order,
array  $records 
)
protected

Definition at line 128 of file ScheduleTable.php.

128 : array
129 {
130 $order_data = $order->get();
131 if ($order_data === []) {
132 return $records;
133 }
134
135 foreach ($order_data as $key => $value) {
136 $order_direction = $value === Order::DESC ? -1 : 1;
137 $callable = match ($key) {
138 'title' => static fn(array $a, array $b): int => strcmp($a['title'], $b['title']) * $order_direction,
139 'is_used' => static fn(array $a, array $b): int => (($a['is_used'] ?? false) <=> ($b['is_used'] ?? false)) * -$order_direction,
140 default => null,
141 };
142
143 if ($callable === null) {
144 continue;
145 }
146
147 usort($records, $callable);
148 }
149
150 return $records;
151 }
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\Schedule\Table\ScheduleTable::ACTION_PARAMETER = 'action'

Definition at line 54 of file ScheduleTable.php.

◆ ACTION_TYPE_PARAMETER

const ILIAS\BookingManager\Schedule\Table\ScheduleTable::ACTION_TYPE_PARAMETER = 'action_type'

Definition at line 56 of file ScheduleTable.php.

◆ ID

const ILIAS\BookingManager\Schedule\Table\ScheduleTable::ID = 'bksd'

◆ ROW_ID_PARAMETER

const ILIAS\BookingManager\Schedule\Table\ScheduleTable::ROW_ID_PARAMETER = 'schedule_id'

Definition at line 52 of file ScheduleTable.php.


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