|
71 | 71 | use PhpSchool\Website\InputFilter\Login as LoginInputFilter; |
72 | 72 | use PhpSchool\Website\InputFilter\SubmitWorkshop as SubmitWorkshopInputFilter; |
73 | 73 | use PhpSchool\Website\InputFilter\WorkshopComposerJson as WorkshopComposerJsonInputFilter; |
74 | | -use PhpSchool\Website\Middleware\FpcCache; |
75 | 74 | use PhpSchool\Website\Middleware\Session as SessionMiddleware; |
76 | | -use PhpSchool\Website\PhpRenderer; |
77 | 75 | use PhpSchool\Website\Repository\DoctrineORMBlogRepository; |
78 | 76 | use PhpSchool\Website\Repository\EventRepository; |
79 | 77 | use PhpSchool\Website\Repository\WorkshopInstallRepository; |
|
122 | 120 | 'app' => factory(function (ContainerInterface $c): App { |
123 | 121 | $app = Bridge::create($c); |
124 | 122 | $app->addRoutingMiddleware(); |
125 | | - $app->add($c->get(FpcCache::class)); |
126 | 123 |
|
127 | 124 | $app->add(function (Request $request, RequestHandler $handler) use($c) : Response { |
128 | | - $renderer = $this->get(PhpRenderer::class); |
129 | 125 | /** @var Session $session */ |
130 | 126 | $session = $this->get(Session::class); |
131 | 127 |
|
132 | 128 | $student = $session->get('student'); |
133 | 129 |
|
134 | 130 | $request = $request->withAttribute('student', $student); |
135 | | - $renderer->addAttribute('student', $student); |
136 | | - $renderer->addAttribute( |
137 | | - 'totalExerciseCount', |
138 | | - $c->get(CloudWorkshopRepository::class)->totalExerciseCount() |
139 | | - ); |
140 | 131 |
|
141 | 132 | return $handler->handle($request) |
142 | 133 | ->withHeader('cache-control', 'no-cache'); |
143 | 134 | }); |
144 | 135 | $app->add(StudentRefresher::class); |
145 | 136 | $app->add(new SessionMiddleware(['name' => 'phpschool'])); |
146 | 137 |
|
147 | | - $app->add(function (Request $request, RequestHandler $handler) use ($c){ |
148 | | - $renderer = $c->get(PhpRenderer::class); |
149 | | - $renderer->addAttribute('userAgent', new Agent); |
150 | | - $renderer->addAttribute('route', $request->getUri()->getPath()); |
151 | | - |
152 | | - return $handler->handle($request); |
153 | | - }); |
154 | | - |
155 | 138 | return $app; |
156 | 139 | }), |
157 | | - FpcCache::class => factory(function (ContainerInterface $c): FpcCache { |
158 | | - return new FpcCache($c->get('cache.fpc')); |
159 | | - }), |
160 | | - 'cache.fpc' => factory(function (ContainerInterface $c): CacheInterface { |
161 | | - if (!$c->get('config')['enablePageCache']) { |
162 | | - return new NullAdapter; |
163 | | - } |
164 | | - return new RedisAdapter(new Predis\Client(['host' => $c->get('config')['redisHost']]), 'fpc'); |
165 | | - }), |
166 | 140 | 'cache' => factory(function (ContainerInterface $c): CacheInterface { |
167 | 141 | if (!$c->get('config')['enableCache']) { |
168 | 142 | return new NullAdapter; |
|
183 | 157 |
|
184 | 158 | return new RedisAdapter($redisConnection, 'default'); |
185 | 159 | }), |
186 | | - PhpRenderer::class => factory(function (ContainerInterface $c): PhpRenderer { |
187 | | - |
188 | | - $settings = $c->get('config')['renderer']; |
189 | | - $renderer = new PhpRenderer( |
190 | | - $settings['template_path'], |
191 | | - [ |
192 | | - 'links' => $c->get('config')['links'], |
193 | | - ], |
194 | | - ); |
195 | | - |
196 | | - return $renderer; |
197 | | - }), |
198 | 160 | LoggerInterface::class => factory(function (ContainerInterface $c): LoggerInterface{ |
199 | 161 | $settings = $c->get('config')['logger']; |
200 | 162 | $logger = new Logger($settings['name']); |
|
215 | 177 |
|
216 | 178 | //commands |
217 | 179 | ClearCache::class => factory(function (ContainerInterface $c): ClearCache { |
218 | | - return new ClearCache($c->get('cache.fpc')); |
| 180 | + return new ClearCache($c->get('cache')); |
219 | 181 | }), |
220 | 182 | CreateAdminUser::class => factory(function (ContainerInterface $c): CreateAdminUser { |
221 | 183 | return new CreateAdminUser($c->get(EntityManagerInterface::class)); |
|
275 | 237 |
|
276 | 238 | ClearCacheAction::class => function (ContainerInterface $c): ClearCacheAction { |
277 | 239 | return new ClearCacheAction( |
278 | | - $c->get('cache.fpc'), |
| 240 | + $c->get('cache'), |
279 | 241 | ); |
280 | 242 | }, |
281 | 243 |
|
282 | 244 | Requests::class => \DI\factory(function (ContainerInterface $c): Requests { |
283 | 245 | return new Requests( |
284 | 246 | $c->get(WorkshopRepository::class), |
285 | | - $c->get(PhpRenderer::class) |
286 | 247 | ); |
287 | 248 | }), |
288 | 249 |
|
289 | 250 | All::class => \DI\factory(function (ContainerInterface $c): All { |
290 | 251 | return new All( |
291 | 252 | $c->get(WorkshopRepository::class), |
292 | 253 | $c->get(WorkshopInstallRepository::class), |
293 | | - $c->get(PhpRenderer::class) |
294 | 254 | ); |
295 | 255 | }), |
296 | 256 |
|
297 | 257 | Approve::class => \DI\factory(function (ContainerInterface $c): Approve { |
298 | 258 | return new Approve( |
299 | 259 | $c->get(WorkshopRepository::class), |
300 | 260 | $c->get(WorkshopFeed::class), |
301 | | - $c->get('cache.fpc'), |
| 261 | + $c->get('cache'), |
302 | 262 | $c->get(EmailNotifier::class), |
303 | 263 | $c->get(LoggerInterface::class) |
304 | 264 | ); |
|
308 | 268 | return new Promote( |
309 | 269 | $c->get(WorkshopRepository::class), |
310 | 270 | $c->get(WorkshopFeed::class), |
311 | | - $c->get('cache.fpc'), |
| 271 | + $c->get('cache'), |
312 | 272 | ); |
313 | 273 | }), |
314 | 274 |
|
|
317 | 277 | $c->get(WorkshopRepository::class), |
318 | 278 | $c->get(WorkshopInstallRepository::class), |
319 | 279 | $c->get(WorkshopFeed::class), |
320 | | - $c->get('cache.fpc'), |
| 280 | + $c->get('cache'), |
321 | 281 | ); |
322 | 282 | }), |
323 | 283 |
|
324 | 284 | View::class => function (ContainerInterface $c): View { |
325 | 285 | return new View( |
326 | 286 | $c->get(WorkshopRepository::class), |
327 | 287 | $c->get(WorkshopInstallRepository::class), |
328 | | - $c->get(PhpRenderer::class) |
329 | 288 | ); |
330 | 289 | }, |
331 | 290 |
|
|
410 | 369 | }, |
411 | 370 |
|
412 | 371 | EventAll::class => function (ContainerInterface $c): EventAll { |
413 | | - return new EventAll($c->get(EventRepository::class), $c->get(PhpRenderer::class)); |
| 372 | + return new EventAll($c->get(EventRepository::class)); |
414 | 373 | }, |
415 | 374 |
|
416 | 375 | EventCreate::class => function (ContainerInterface $c): EventCreate { |
|
424 | 383 | return new EventUpdate( |
425 | 384 | $c->get(EventRepository::class), |
426 | 385 | $c->get('form.event'), |
427 | | - $c->get(PhpRenderer::class), |
428 | 386 | ); |
429 | 387 | }, |
430 | 388 |
|
431 | 389 | EventDelete::class => function (ContainerInterface $c): EventDelete { |
432 | 390 | return new EventDelete( |
433 | 391 | $c->get(EventRepository::class), |
434 | | - $c->get('cache.fpc'), |
| 392 | + $c->get('cache'), |
435 | 393 | ); |
436 | 394 | }, |
437 | 395 |
|
|
473 | 431 | StudentAuthenticator::class => function (ContainerInterface $c): StudentAuthenticator { |
474 | 432 | return new StudentAuthenticator( |
475 | 433 | $c->get(Session::class), |
476 | | - $c->get(StudentRepository::class) |
477 | 434 | ); |
478 | 435 | }, |
479 | 436 |
|
@@ -528,10 +485,6 @@ public function parse($markdown): string |
528 | 485 | ); |
529 | 486 | }, |
530 | 487 |
|
531 | | - Styles::class => function (ContainerInterface $c) { |
532 | | - return new Styles($c->get(PhpRenderer::class)); |
533 | | - }, |
534 | | - |
535 | 488 | CloudWorkshopRepository::class => function (ContainerInterface $c): CloudWorkshopRepository { |
536 | 489 | return new CloudWorkshopRepository($c->get(WorkshopRepository::class)); |
537 | 490 | }, |
@@ -602,7 +555,6 @@ public function parse($markdown): string |
602 | 555 | 'github-website' => 'https://github.com/php-school/phpschool.io', |
603 | 556 | ], |
604 | 557 |
|
605 | | - 'enablePageCache' => filter_var($_ENV['CACHE.FPC.ENABLE'], FILTER_VALIDATE_BOOLEAN), |
606 | 558 | 'enableCache' => filter_var($_ENV['CACHE.ENABLE'], FILTER_VALIDATE_BOOLEAN), |
607 | 559 | 'redisHost' => $_ENV['REDIS_HOST'], |
608 | 560 | 'devMode' => filter_var($_ENV['DEV_MODE'], FILTER_VALIDATE_BOOLEAN), |
|
0 commit comments