ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
RandomQuestionSetNonAvailablePoolsTable.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Test\Questions;
22
23use Generator;
24use ILIAS\Data\Factory as DataFactory;
31use ILIAS\UI\Component\Table\Data as DataTable;
32use ILIAS\UI\Factory as UIFactory;
36use Psr\Http\Message\ServerRequestInterface;
37
39{
40 public function __construct(
41 protected readonly \ilCtrlInterface $ctrl,
42 protected readonly \ilLanguage $lng,
43 protected readonly UIFactory $ui_factory,
44 protected readonly DataFactory $data_factory,
45 protected readonly ServerRequestInterface $request,
46 protected readonly PoolDefinitionList $pool_definition_list
47 ) {
48 }
49
50 public function getRows(
51 DataRowBuilder $row_builder,
52 array $visible_column_ids,
54 Order $order,
55 mixed $additional_viewcontrol_data,
56 mixed $filter_data,
57 mixed $additional_parameters
58 ): Generator {
59 foreach ($this->getData($range, $order) as $record) {
61
62 $record['status'] = $this->lng->txt('tst_non_avail_pool_msg_status_' . $record['status']);
63 yield $row_builder
64 ->buildDataRow((string) $record['id'], $record)
65 ->withDisabledAction('derive_pool', !$derive);
66 }
67 }
68
69 public function getTotalRowCount(
70 mixed $additional_viewcontrol_data,
71 mixed $filter_data,
72 mixed $additional_parameters
73 ): ?int {
74 return count($this->pool_definition_list->getNonAvailablePools());
75 }
76
77 protected function getData(Range $range, Order $order): array
78 {
79 $data = array_map(fn($pool) => [
80 'id' => $pool->getId(),
81 'title' => $pool->getTitle(),
82 'path' => $pool->getPath(),
83 'status' => $pool->getUnavailabilityStatus(),
84 ], $this->pool_definition_list->getNonAvailablePools());
85 return array_slice($data, $range->getStart(), $range->getLength());
86 }
87
88 public function getComponent(): DataTable
89 {
90 return $this->ui_factory->table()
91 ->data($this, $this->lng->txt('tst_non_avail_pools_table'), $this->getColumns())
92 ->withRequest($this->request)
93 ->withActions($this->getActions())
94 ->withId('tst_non_avail_pools_table');
95 }
96
100 protected function getColumns(): array
101 {
102 $column_factory = $this->ui_factory->table()->column();
103 return [
104 'title' => $column_factory->text($this->lng->txt('title')),
105 'path' => $column_factory->text($this->lng->txt('path')),
106 'status' => $column_factory->text($this->lng->txt('status')),
107 ];
108 }
109
113 protected function getActions(): array
114 {
115 $target = $this->data_factory->uri((string) $this->request->getUri());
116 $url_builder = new URLBuilder($target);
117 [$url_builder, $id_token] = $url_builder->acquireParameters(
118 ['derive_pool'],
119 'ids'
120 );
121 return [
122 'derive_pool' => $this->ui_factory->table()->action()->single(
123 $this->lng->txt('tst_derive_new_pool'),
124 $url_builder->withURI($target->withParameter('cmd', ConfigGUI::CMD_SELECT_DERIVATION_TARGET)),
125 $id_token
126 )
127 ];
128 }
129}
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
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...
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....
__construct(protected readonly \ilCtrlInterface $ctrl, protected readonly \ilLanguage $lng, protected readonly UIFactory $ui_factory, protected readonly DataFactory $data_factory, protected readonly ServerRequestInterface $request, protected readonly PoolDefinitionList $pool_definition_list)
language handling
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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