ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
LocalDIC.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\Questions\AnswerForm\Factory as AnswerFormFactory;
28use ILIAS\Questions\Attempt\Repository as AttemptRepository;
29use ILIAS\Questions\Attempt\TableDefinitions as AttemptTableDefinitions;
32use ILIAS\Questions\Question\Persistence\TableDefinitions as QuestionTableDefinitions;
34use ILIAS\Questions\Persistence\Factory as PersistenceFactory;
39use ILIAS\Data\Factory as DataFactory;
40use ILIAS\Data\UUID\Factory as UuidFactory;
41use ILIAS\DI\Container as ILIASContainer;
44use Mustache\Engine as MustacheEngine;
45use Pimple\Container as PimpleContainer;
46
47class LocalDIC extends PimpleContainer
48{
49 protected static ?self $dic = null;
50
51 public static function dic(): self
52 {
53 if (!self::$dic) {
54 global $DIC;
56 }
57 return self::$dic;
58 }
59
60 protected static function buildDIC(ILIASContainer $DIC): self
61 {
62 $dic = new self();
63 $dic[DataFactory::class] = static fn($c): DataFactory => new DataFactory();
64 $dic[UuidFactory::class] = static fn($c): UuidFactory => new UuidFactory();
65 $dic[MustacheEngine::class] = static fn($c): MustacheEngine
66 => new MustacheEngine(['escape' => static fn($v) => $v]);
67 $dic[FilenameSanitizer::class] = static fn($c): FilenameSanitizer
69 $DIC->fileServiceSettings()
70 );
71
72 $dic[PublicInterface::class] = static fn($c): PublicInterface
74 $DIC['lng'],
75 $DIC['user']->getLoggedInUser(),
76 $DIC['refinery'],
77 $DIC['ui.factory'],
78 $DIC['ui.renderer'],
79 $DIC['global_screen'],
80 $DIC['tpl'],
81 $DIC->contentStyle(),
82 $DIC['ilCtrl'],
83 $DIC['http'],
84 $DIC['ilTabs'],
85 $DIC->uiService(),
86 $c[UuidFactory::class],
87 $c[ConfigurationRepository::class],
88 $c[AnswerFormFactory::class],
89 $c[QuestionsRepository::class],
90 $c[AttemptRepository::class],
91 $c[LayoutFactory::class],
92 $c[Capabilities\Factory::class]
93 );
94
95 $dic[ConfigurationRepository::class] = static fn($c): ConfigurationRepository
97 $DIC['ilSetting'],
98 $DIC['user']->getSettings()->getSettingByDefinitionClass(
99 CreateMode::class
100 ),
101 new \ilSetting('questions')
102 );
103 $dic[PersistenceFactory::class] = static fn($c): PersistenceFactory
104 => new PersistenceFactory();
105 $dic[QuestionTableDefinitions::class] = static fn($c): QuestionTableDefinitions
106 => new QuestionTableDefinitions(
107 $c[PersistenceFactory::class]
108 );
109 $dic[AnswerFormGenericTableDefinitions::class] = static fn($c): AnswerFormGenericTableDefinitions
111 $c[PersistenceFactory::class]
112 );
113 $dic[DatabaseStatementBuilder::class] = static fn($c): DatabaseStatementBuilder
115 $c[PersistenceFactory::class],
116 $c[QuestionTableDefinitions::class],
117 $c[AnswerFormGenericTableDefinitions::class]
118 );
119 $dic[AttemptTableDefinitions::class] = static fn($c): AttemptTableDefinitions
120 => new AttemptTableDefinitions(
121 $c[PersistenceFactory::class]
122 );
123 $dic[AttemptRepository::class] = static fn($c): AttemptRepository
124 => new AttemptRepository(
125 $DIC['ilDB'],
126 $DIC['refinery'],
127 $c[UuidFactory::class],
128 $c[PersistenceFactory::class],
129 $c[AttemptTableDefinitions::class]
130 );
131 $dic[Capabilities\Factory::class] = static fn($c): Capabilities\Factory
132 => new Capabilities\Factory([
133 new Capabilities\TextFeedback\Capability(
134 $c[DataFactory::class]->text(),
135 new Capabilities\TextFeedback\Repository(
136 $DIC['ilDB'],
137 $DIC['refinery'],
138 $c[UuidFactory::class],
139 $c[DataFactory::class]->text(),
140 $c[PersistenceFactory::class],
141 new Capabilities\TextFeedback\TableDefinitions(
142 $c[PersistenceFactory::class]
143 )
144 )
145 ),
147 $DIC['ilCtrl'],
148 $DIC['rbacsystem'],
149 $DIC['tree'],
150 $DIC['static_url'],
151 $DIC['user']->getLoggedInUser(),
153 $DIC['ilDB'],
154 $DIC['refinery'],
155 $DIC['resource_storage'],
156 $c[PersistenceFactory::class],
158 $c[PersistenceFactory::class]
159 )
160 )
161 ),
162 new Capabilities\MarkingAllowingPartialPoints\Capability(),
163 new Capabilities\DefaultView\Capability(),
164 new Capabilities\AsyncView\Capability()
165 ]);
166 $dic[AnswerFormFactory::class] = static fn($c): AnswerFormFactory
167 => new AnswerFormFactory(
168 $c[UuidFactory::class],
169 [
170 $c[Cloze\Definition::class]
171 ]
172 );
173 $dic[QuestionsRepository::class] = static fn($c): QuestionsRepository
174 => new QuestionsRepository(
175 $DIC['ilDB'],
176 $DIC['refinery'],
177 $c[UuidFactory::class],
178 $c[DatabaseStatementBuilder::class],
179 $c[PersistenceFactory::class],
180 $c[QuestionTableDefinitions::class],
181 $c[AnswerFormGenericTableDefinitions::class],
182 $c[AnswerFormFactory::class]
183 );
184 $dic[LayoutFactory::class] = static fn($c): LayoutFactory =>
185 new LayoutFactory(
186 $DIC['ui.factory'],
187 $DIC['http'],
188 $DIC['lng'],
189 $DIC['resource_storage'],
190 $DIC['filesystem']->temp(),
191 $DIC['upload'],
192 $c[FilenameSanitizer::class]
193 );
194 $dic[Cloze\Properties\ClozeText\Factory::class] = static fn($c): Cloze\Properties\ClozeText\Factory
195 => new Cloze\Properties\ClozeText\Factory(
196 $DIC['refinery'],
197 $c[MustacheEngine::class],
198 $c[DataFactory::class]->text()
199 );
200 $dic[Cloze\Properties\Gaps\AnswerOptions\Factory::class] = static fn($c): Cloze\Properties\Gaps\AnswerOptions\Factory
201 => new Cloze\Properties\Gaps\AnswerOptions\Factory(
202 $c[UuidFactory::class],
203 $DIC['refinery']
204 );
205 $dic[Cloze\Properties\Gaps\Factory::class] = static fn($c): Cloze\Properties\Gaps\Factory
206 => new Cloze\Properties\Gaps\Factory(
207 $DIC['refinery'],
208 $c[UuidFactory::class],
209 $c[Cloze\Properties\Gaps\AnswerOptions\Factory::class],
210 [
211 new Cloze\Properties\Gaps\Text(
212 $DIC['lng'],
213 $DIC['refinery']
214 ),
215 new Cloze\Properties\Gaps\Numeric(
216 $DIC['lng'],
217 $DIC['refinery']
218 ),
219 new Cloze\Properties\Gaps\Select(
220 $DIC['lng'],
221 $DIC['refinery']
222 ),
223 new Cloze\Properties\Gaps\LongMenu(
224 $DIC['lng'],
225 $DIC['refinery'],
226 $DIC['tpl']
227 )
228 ]
229 );
230 $dic[Cloze\TableDefinitions::class] = static fn($c): Cloze\TableDefinitions
231 => new Cloze\TableDefinitions(
232 $c[PersistenceFactory::class],
234 'ILIAS',
235 'cloze'
236 )
237 );
238 $dic[Cloze\Properties\Factory::class] = static fn($c): Cloze\Properties\Factory
239 => new Cloze\Properties\Factory(
240 $c[PersistenceFactory::class],
241 $c[Cloze\Properties\ClozeText\Factory::class],
242 $c[Cloze\Properties\Gaps\Factory::class],
243 $c[Cloze\Properties\Combinations\Factory::class]
244 );
245 $dic[Cloze\Response\Factory::class] = static fn($c): Cloze\Response\Factory
246 => new Cloze\Response\Factory(
247 $c[UuidFactory::class],
248 $c[PersistenceFactory::class]
249 );
250 $dic[Cloze\Properties\Gaps\Edit::class] = static fn($c): Cloze\Properties\Gaps\Edit
251 => new Cloze\Properties\Gaps\Edit(
252 $DIC['upload'],
253 $c[Cloze\Properties\Factory::class],
254 $c[Cloze\Properties\Gaps\Factory::class]
255 );
256 $dic[Cloze\Views\Edit::class] = static fn($c): Cloze\Views\Edit
257 => new Cloze\Views\Edit(
258 $c[Cloze\Properties\Factory::class],
259 $c[Cloze\Properties\ClozeText\Factory::class],
260 $c[Cloze\Properties\Gaps\Edit::class]
261 );
262 $dic[Cloze\Definition::class] = static fn($c): Cloze\Definition => new Cloze\Definition(
263 $c[Cloze\TableDefinitions::class],
264 [
265 new Cloze\Capabilities\TextFeedback(
266 $c[UuidFactory::class],
267 $c[DataFactory::class]->text()
268 ),
269 new Cloze\Capabilities\MarkingAllowingPartialPoints(
270 $c[Cloze\Properties\Factory::class],
271 $c[Cloze\Response\Factory::class]
272 ),
273 new Cloze\Capabilities\DefaultView(
274 $c[MustacheEngine::class],
275 $c[Cloze\Response\Factory::class]
276 ),
277 new Cloze\Capabilities\AsyncView(
278 $DIC['ui.renderer'],
279 $c[MustacheEngine::class],
280 $c[Cloze\Response\Factory::class]
281 )
282 ],
283 $c[Cloze\Properties\Factory::class],
284 $c[Cloze\Response\Factory::class],
285 $c[Cloze\Views\Edit::class]
286 );
287 $dic[Cloze\Properties\Combinations\Factory::class] = static fn($c): Cloze\Properties\Combinations\Factory
288 => new Cloze\Properties\Combinations\Factory(
289 $c[UuidFactory::class],
290 $c[PersistenceFactory::class],
291 $c[Cloze\TableDefinitions::class]
292 );
293
294 return $dic;
295 }
296}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:38
Builds data types.
Definition: Factory.php:36
Standard implementation of the filename sanitizing interface.
static buildDIC(ILIASContainer $DIC)
Definition: LocalDIC.php:60
ILIAS Setting Class.
The filename sanitizer verifies and fixes file name endings.
global $DIC
Definition: shib_login.php:26