ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
TestDIC.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Test;
22
24use ILIAS\Test\Results\Data\Repository as TestResultRepository;
31use ILIAS\Test\Settings\GlobalSettings\Repository as GlobalSettingsRepository;
37use ILIAS\Test\Logging\Factory as InteractionFactory;
38use ILIAS\Test\ExportImport\Factory as ExportImportFactory;
39use ILIAS\Test\ExportImport\DBRepository as ExportImportRepository;
40use ILIAS\Test\Questions\Properties\Repository as TestQuestionsRepository;
41use ILIAS\Test\Questions\Properties\DatabaseRepository as TestQuestionsDatabaseRepository;
42use ILIAS\Test\Results\Data\Factory as ResultsDataFactory;
43use ILIAS\Test\Results\Presentation\Factory as ResultsPresentationFactory;
46use ILIAS\TestQuestionPool\RequestDataCollector as QPLRequestDataCollector;
47use ILIAS\Data\Factory as DataFactory;
48use ILIAS\DI\Container as ILIASContainer;
49use Pimple\Container as PimpleContainer;
50
51class TestDIC extends PimpleContainer
52{
53 protected static ?self $dic = null;
54
55 public static function dic(): self
56 {
57 if (!self::$dic) {
58 global $DIC;
60 }
61 return self::$dic;
62 }
63
64 protected static function buildDIC(ILIASContainer $DIC): self
65 {
66 $dic = new self();
67 $dic['shuffler'] = static fn($c): \ilTestShuffler =>
68 new \ilTestShuffler($DIC['refinery']);
69
70 $dic['title_columns_builder'] = static fn($c): TitleColumnsBuilder =>
72 $c['question.general_properties.repository'],
73 $DIC['ilCtrl'],
74 $DIC['ilAccess'],
75 $DIC['lng'],
76 $DIC['static_url'],
77 $DIC['ui.factory'],
78 $DIC['refinery']
79 );
80
81 $dic['results.data.factory'] = static fn($c): ResultsDataFactory =>
82 new ResultsDataFactory(
83 $c['shuffler'],
84 $DIC['ui.factory'],
85 $DIC['ui.renderer']
86 );
87
88 $dic['results.presentation.factory'] = static fn($c): ResultsPresentationFactory =>
89 new ResultsPresentationFactory(
90 $DIC['ui.factory'],
91 $DIC['ui.renderer'],
92 $DIC['refinery'],
93 new DataFactory(),
94 $DIC['http'],
95 $DIC['lng']
96 );
97
98 $dic['results.toplist.repository'] = static fn($c): TestTopListRepository =>
99 new TestTopListRepository($DIC['ilDB']);
100
101 $dic['results.data.repository'] = static fn($c): TestResultRepository =>
102 new TestResultRepository(
103 $DIC->database(),
104 $DIC->refinery(),
105 $c['marks.repository'],
106 $DIC->globalCache()
107 );
108
109 $dic['settings.main.repository'] = static fn($c): MainSettingsRepository =>
111
112 $dic['participant.access_filter.factory'] = static fn($c): \ilTestParticipantAccessFilterFactory =>
113 new \ilTestParticipantAccessFilterFactory($DIC['ilAccess']);
114
115 $dic['scoring.manual.done_helper'] = static fn($c): TestManScoringDoneHelper =>
117
118 $dic['marks.repository'] = static fn($c): MarksRepository =>
119 new MarksDatabaseRepository($DIC['ilDB']);
120
121 $dic['request_data_collector'] = static fn($c): RequestDataCollector =>
123 $DIC['http'],
124 $DIC['refinery']
125 );
126
127 $dic['response_handler'] = static fn($c): ResponseHandler =>
128 new ResponseHandler($DIC['http'], );
129
130 $dic['settings.global.repository'] = static fn($c): GlobalSettingsRepository =>
131 new GlobalSettingsRepository($DIC['ilSetting'], new \ilSetting('assessment'));
132
133 $dic['logging.settings'] = static fn($c): TestLoggingSettings =>
134 $c['settings.global.repository']->getLoggingSettings();
135
136 $dic['logging.factory'] = static fn($c): InteractionFactory =>
137 new InteractionFactory();
138
139 $dic['logging.repository'] = static fn($c): TestLoggingRepository =>
141 $c['logging.factory'],
142 $DIC['ilDB']
143 );
144
145 $dic['logging.logger'] = static fn($c): TestLogger =>
146 new TestLogger(
147 $c['logging.settings'],
148 $c['logging.repository'],
149 $c['logging.factory'],
150 new Logging\AdditionalInformationGenerator(
151 (new \ilMustacheFactory())->getBasicEngine(),
152 $DIC['lng'],
153 $DIC['ui.factory'],
154 $DIC['refinery'],
155 $c['question.general_properties.repository']
156 ),
158 );
159
160 $dic['logging.viewer'] = static fn($c): TestLogViewer =>
161 new TestLogViewer(
162 $c['logging.repository'],
163 $c['logging.logger'],
164 $c['title_columns_builder'],
165 $c['question.general_properties.repository'],
166 $DIC['http']->request(),
167 $DIC['http']->wrapper()->query(),
168 $DIC->uiService(),
169 $DIC['ui.factory'],
170 $DIC['ui.renderer'],
171 $DIC['refinery'],
172 $DIC['lng'],
173 $DIC['tpl'],
174 $DIC['file_delivery']->delivery(),
175 $DIC['ilUser']
176 );
177
178 $dic['exportimport.factory'] = static fn($c): ExportImportFactory =>
179 new ExportImportFactory(
180 $DIC['lng'],
181 $DIC['ilDB'],
182 $DIC['ilBench'],
183 $DIC['tpl'],
184 $c['logging.logger'],
185 $DIC['tree'],
186 $DIC['component.repository'],
187 $DIC['component.factory'],
188 $DIC['file_delivery'],
189 $DIC['ilUser'],
190 $c['question.general_properties.repository'],
191 $DIC['resource_storage'],
192 );
193
194 $dic['exportimport.repository'] = static fn($c): ExportImportRepository =>
195 new ExportImportRepository(
196 $DIC['ilDB']
197 );
198
199 $dic['questions.properties.repository'] = static fn($c): TestQuestionsRepository =>
200 new TestQuestionsDatabaseRepository(
201 $DIC['ilDB'],
202 $c['question.general_properties.repository']
203 );
204
205 $dic['question.general_properties.repository'] = static fn($c): GeneralQuestionPropertiesRepository =>
207 $DIC['ilDB'],
208 $DIC['component.factory'],
209 $DIC['component.repository']
210 );
211
212 $dic['question.request_data_wrapper'] = static fn($c): QPLRequestDataCollector =>
213 new QPLRequestDataCollector(
214 $DIC->http(),
215 $DIC['refinery'],
216 $DIC['upload']
217 );
218
219 $dic['participant.repository'] = static fn($c): ParticipantRepository =>
220 new ParticipantRepository($DIC['ilDB']);
221
222 return $dic;
223 }
224}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Builds data types.
Definition: Factory.php:36
static self $dic
Definition: TestDIC.php:53
static buildDIC(ILIASContainer $DIC)
Definition: TestDIC.php:64
static dic()
Definition: TestDIC.php:55
static getLogger(string $a_component_id)
Get component logger.
ILIAS Setting Class.
$c
Definition: deliver.php:25
$dic
Definition: ltiresult.php:33
global $DIC
Definition: shib_login.php:26