ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
LDAPRoleAssignmentTable Class Reference
+ Inheritance diagram for LDAPRoleAssignmentTable:
+ Collaboration diagram for LDAPRoleAssignmentTable:

Public Member Functions

 __construct (private readonly ServerRequestInterface $http_request, private readonly ilLanguage $lng, private readonly UIFactory $ui_factory, private readonly \ILIAS\Data\URI $action_url, private readonly int $server_id, private readonly bool $has_write_access)
 
 getRows (ILIAS\UI\Component\Table\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...
 
 getComponent ()
 
 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...
 
 getActions (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
 
 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...
 

Private Member Functions

 getRecords (Range $range, Order $order)
 
 limitRecords (array $records, Range $range)
 
 orderRecords (array $records, Order $order)
 
 getColumns ()
 

Private Attributes

array $records = null
 

Detailed Description

Definition at line 33 of file LDAPRoleAssignmentTable.php.

Constructor & Destructor Documentation

◆ __construct()

LDAPRoleAssignmentTable::__construct ( private readonly ServerRequestInterface  $http_request,
private readonly ilLanguage  $lng,
private readonly UIFactory  $ui_factory,
private readonly \ILIAS\Data\URI  $action_url,
private readonly int  $server_id,
private readonly bool  $has_write_access 
)

Definition at line 45 of file LDAPRoleAssignmentTable.php.

52 {
53 }

Member Function Documentation

◆ getActions()

LDAPRoleAssignmentTable::getActions ( URLBuilder  $url_builder,
URLBuilderToken  $action_parameter_token,
URLBuilderToken  $row_id_token 
)
Returns
array<string, Action[]>

Definition at line 168 of file LDAPRoleAssignmentTable.php.

172 : array {
173 $actions = [];
174 if ($this->has_write_access) {
175 $actions['delete'] = $this->ui_factory->table()->action()->multi(
176 $this->lng->txt('delete'),
177 $url_builder->withParameter($action_parameter_token, 'confirmDeleteRules'),
178 $row_id_token
179 );
180 }
181
182 $actions['edit'] = $this->ui_factory->table()->action()->single(
183 $this->has_write_access ? $this->lng->txt('edit') : $this->lng->txt('view'),
184 $url_builder->withParameter($action_parameter_token, 'editRoleAssignment'),
185 $row_id_token
186 );
187
188 return $actions;
189 }
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166

References ILIAS\Repository\lng(), and ILIAS\UI\URLBuilder\withParameter().

+ Here is the call graph for this function:

◆ getColumns()

LDAPRoleAssignmentTable::getColumns ( )
private
Returns
array<string, Column>

Definition at line 253 of file LDAPRoleAssignmentTable.php.

253 : array
254 {
255 return [
256 'type' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_rule_type')),
257 'role' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_ilias_role')),
258 'condition' => $this->ui_factory->table()->column()->text($this->lng->txt('ldap_rule_condition')),
259 'add' => $this->ui_factory->table()->column()->statusIcon($this->lng->txt('ldap_add_roles'))
260 ->withIsSortable(false),
261 'remove' => $this->ui_factory->table()->column()->statusIcon($this->lng->txt('ldap_remove_roles'))
262 ->withIsSortable(false),
263 ];
264 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponent()

LDAPRoleAssignmentTable::getComponent ( )

Definition at line 106 of file LDAPRoleAssignmentTable.php.

106 : DataTable
107 {
108 $query_params_namespace = ['ldap', 'role', 'assignment'];
109 $url_builder = new URLBuilder($this->action_url);
110 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
111 $query_params_namespace,
112 'table_action',
113 'rule_ids'
114 );
115
116 return $this->ui_factory->table()
117 ->data(
118 $this,
119 $this->lng->txt('ldap_tbl_role_ass'),
120 $this->getColumns()
121 )
122 ->withActions($this->getActions($url_builder, $action_parameter_token, $row_id_token))
123 ->withId('ldap_role_assignment_table')
124 ->withOrder(new Order('type', Order::DESC))
125 ->withRange(new Range(0, 100))
126 ->withRequest($this->http_request);
127 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRecords()

LDAPRoleAssignmentTable::getRecords ( Range  $range,
Order  $order 
)
private
Returns
list<array{ 'id': int, 'type': string, 'condition': string, 'add': Icon, 'remove': Icon, 'role': string, }>

Definition at line 149 of file LDAPRoleAssignmentTable.php.

149 : array
150 {
151 $this->initRecords();
153
154 if ($order) {
155 $records = $this->orderRecords($records, $order);
156 }
157
158 if ($range) {
159 $records = $this->limitRecords($records, $range);
160 }
161
162 return $records;
163 }
orderRecords(array $records, Order $order)
limitRecords(array $records, Range $range)

References ILIAS\UI\Implementation\Component\Table\$range.

◆ getRows()

LDAPRoleAssignmentTable::getRows ( ILIAS\UI\Component\Table\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 55 of file LDAPRoleAssignmentTable.php.

63 : Generator {
64 $records = $this->getRecords($range, $order);
65 foreach ($records as $record) {
66 yield $row_builder->buildDataRow((string) $record['id'], $record);
67 }
68 }
getRecords(Range $range, Order $order)

◆ getTotalRowCount()

LDAPRoleAssignmentTable::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 129 of file LDAPRoleAssignmentTable.php.

133 : ?int {
134 $this->initRecords();
135
136 return count((array) $this->records);
137 }

◆ limitRecords()

LDAPRoleAssignmentTable::limitRecords ( array  $records,
Range  $range 
)
private
Parameters
list<array{'id': int, 'type': string, 'condition': string, 'add': Icon, 'remove': Icon, 'role': string, }> $records
Returns
list<array{ 'id': int, 'type': string, 'condition': string, 'add': Icon, 'remove': Icon, 'role': string, }>

Definition at line 209 of file LDAPRoleAssignmentTable.php.

209 : array
210 {
211 return array_slice($records, $range->getStart(), $range->getLength());
212 }

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

+ Here is the call graph for this function:

◆ orderRecords()

LDAPRoleAssignmentTable::orderRecords ( array  $records,
Order  $order 
)
private
Parameters
list<array{'id': int, 'type': string, 'condition': string, 'add': Icon, 'remove': Icon, 'role': string, }> $records
Returns
list<array{ 'id': int, 'type': string, 'condition': string, 'add': Icon, 'remove': Icon, 'role': string, }>

Definition at line 232 of file LDAPRoleAssignmentTable.php.

232 : array
233 {
234 [$order_field, $order_direction] = $order->join(
235 [],
236 fn($ret, $key, $value) => [$key, $value]
237 );
238 usort($records, static fn(array $left, array $right): int => ilStr::strCmp(
239 $left[$order_field] ?? '',
240 $right[$order_field] ?? ''
241 ));
242
243 if ($order_direction === Order::DESC) {
244 $records = array_reverse($records);
245 }
246
247 return $records;
248 }
join($init, callable $fn)
Definition: Order.php:75
static strCmp(string $a, string $b)
Definition: class.ilStr.php:87

References ILIAS\Data\Order\join(), and ilStr\strCmp().

+ Here is the call graph for this function:

Field Documentation

◆ $records

array LDAPRoleAssignmentTable::$records = null
private

Definition at line 43 of file LDAPRoleAssignmentTable.php.


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