8
8
use Chimera \ExecuteQuery ;
9
9
use Chimera \IdentifierGenerator ;
10
10
use Chimera \MessageCreator ;
11
+ use Chimera \Routing \Expressive \Application ;
11
12
use Chimera \Routing \Expressive \UriGenerator ;
12
13
use Chimera \Routing \Handler \CreateAndFetch ;
13
14
use Chimera \Routing \Handler \CreateOnly ;
14
15
use Chimera \Routing \Handler \ExecuteAndFetch ;
15
16
use Chimera \Routing \Handler \ExecuteOnly ;
16
17
use Chimera \Routing \Handler \FetchOnly ;
18
+ use Chimera \Routing \MissingRouteDispatching ;
17
19
use Chimera \Routing \RouteParamsExtraction ;
18
20
use Fig \Http \Message \StatusCodeInterface as StatusCode ;
19
21
use Lcobucci \ContentNegotiation \ContentTypeMiddleware ;
20
22
use Lcobucci \ContentNegotiation \Formatter \Json ;
21
- use Psr \Http \Message \ResponseInterface ;
22
- use Psr \Http \Message \ServerRequestInterface ;
23
- use Psr \Http \Message \StreamInterface ;
23
+ use Psr \Http \Message \ResponseFactoryInterface ;
24
+ use Psr \Http \Message \StreamFactoryInterface ;
24
25
use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
25
26
use Symfony \Component \DependencyInjection \Compiler \ServiceLocatorTagPass ;
26
27
use Symfony \Component \DependencyInjection \ContainerBuilder ;
27
28
use Symfony \Component \DependencyInjection \Definition ;
28
29
use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
29
30
use Symfony \Component \DependencyInjection \Reference ;
30
- use Zend \Expressive \ Application ;
31
- use Zend \Expressive \Handler \ NotFoundHandler ;
31
+ use Zend \Diactoros \ ServerRequestFactory ;
32
+ use Zend \Expressive \Application as Expressive ;
32
33
use Zend \Expressive \Helper \BodyParams \BodyParamsMiddleware ;
33
34
use Zend \Expressive \Middleware \LazyLoadingMiddleware ;
34
35
use Zend \Expressive \MiddlewareContainer ;
@@ -289,7 +290,7 @@ private function registerApplication(
289
290
$ middlewarePipeline ->addMethodCall ('pipe ' , [new Reference (MethodNotAllowedMiddleware::class)]);
290
291
$ middlewarePipeline ->addMethodCall ('pipe ' , [new Reference (RouteParamsExtraction::class)]);
291
292
$ middlewarePipeline ->addMethodCall ('pipe ' , [new Reference (DispatchMiddleware::class)]);
292
- $ middlewarePipeline ->addMethodCall ('pipe ' , [new Reference (NotFoundHandler ::class)]);
293
+ $ middlewarePipeline ->addMethodCall ('pipe ' , [new Reference (MissingRouteDispatching ::class)]);
293
294
294
295
$ container ->setDefinition ($ this ->applicationName . '.http.middleware_pipeline ' , $ middlewarePipeline );
295
296
@@ -345,7 +346,7 @@ private function registerApplication(
345
346
ImplicitHeadMiddleware::class,
346
347
[
347
348
new Reference ($ this ->applicationName . '.http.router ' ),
348
- new Reference (StreamInterface ::class),
349
+ [ new Reference (StreamFactoryInterface ::class), ' createStream ' ] ,
349
350
]
350
351
);
351
352
@@ -375,7 +376,7 @@ private function registerApplication(
375
376
$ container ->hasParameter ($ applicationAllowedFormats ) ? '% ' . $ applicationAllowedFormats . '% '
376
377
: '%chimera.default_allowed_formats% ' ,
377
378
$ formatters ,
378
- new Reference (StreamInterface ::class),
379
+ new Reference (StreamFactoryInterface ::class),
379
380
]
380
381
);
381
382
@@ -390,26 +391,30 @@ private function registerApplication(
390
391
[
391
392
new Reference ($ this ->applicationName . '.http.middleware_pipeline ' ),
392
393
new Reference (EmitterInterface::class),
393
- new Reference (ServerRequestInterface ::class) ,
394
+ [ServerRequestFactory ::class, ' fromGlobals ' ] ,
394
395
new Reference (ServerRequestErrorResponseGenerator::class),
395
396
]
396
397
);
397
398
398
399
$ container ->setDefinition ($ this ->applicationName . '.http.request_handler_runner ' , $ requestHandlerRunner );
399
400
400
- $ application = new Definition (
401
- Application::class,
402
- [
403
- new Reference ($ this ->applicationName . '.http.middleware_factory ' ),
404
- new Reference ($ this ->applicationName . '.http.middleware_pipeline ' ),
405
- new Reference ($ this ->applicationName . '.http.route_collector ' ),
406
- new Reference ($ this ->applicationName . '.http.request_handler_runner ' ),
407
- ]
401
+ $ container ->setDefinition (
402
+ $ this ->applicationName . '.http_expressive ' ,
403
+ new Definition (
404
+ Expressive::class,
405
+ [
406
+ new Reference ($ this ->applicationName . '.http.middleware_factory ' ),
407
+ new Reference ($ this ->applicationName . '.http.middleware_pipeline ' ),
408
+ new Reference ($ this ->applicationName . '.http.route_collector ' ),
409
+ new Reference ($ this ->applicationName . '.http.request_handler_runner ' ),
410
+ ]
411
+ )
408
412
);
409
413
410
- $ application ->setPublic (true );
414
+ $ app = new Definition (Application::class, [new Reference ($ this ->applicationName . '.http_expressive ' )]);
415
+ $ app ->setPublic (true );
411
416
412
- $ container ->setDefinition ($ this ->applicationName . '.http ' , $ application );
417
+ $ container ->setDefinition ($ this ->applicationName . '.http ' , $ app );
413
418
}
414
419
415
420
private function generateReadAction (string $ name , string $ query , ContainerBuilder $ container ): Reference
@@ -468,7 +473,7 @@ public function fetchOnly(string $routeServiceId, array $route, ContainerBuilder
468
473
FetchOnly::class,
469
474
[
470
475
$ this ->generateReadAction ($ routeServiceId . '.action ' , $ route ['query ' ], $ container ),
471
- new Reference (ResponseInterface ::class),
476
+ new Reference (ResponseFactoryInterface ::class),
472
477
]
473
478
);
474
479
@@ -486,7 +491,7 @@ public function createOnly(string $routeServiceId, array $route, ContainerBuilde
486
491
CreateOnly::class,
487
492
[
488
493
$ this ->generateWriteAction ($ routeServiceId . '.action ' , $ route ['command ' ], $ container ),
489
- new Reference (ResponseInterface ::class),
494
+ new Reference (ResponseFactoryInterface ::class),
490
495
$ route ['redirect_to ' ],
491
496
new Reference ($ this ->applicationName . '.http.uri_generator ' ),
492
497
new Reference (IdentifierGenerator::class),
@@ -509,7 +514,7 @@ public function createAndFetch(string $routeServiceId, array $route, ContainerBu
509
514
[
510
515
$ this ->generateWriteAction ($ routeServiceId . '.write_action ' , $ route ['command ' ], $ container ),
511
516
$ this ->generateReadAction ($ routeServiceId . '.read_action ' , $ route ['query ' ], $ container ),
512
- new Reference (ResponseInterface ::class),
517
+ new Reference (ResponseFactoryInterface ::class),
513
518
$ route ['redirect_to ' ],
514
519
new Reference ($ this ->applicationName . '.http.uri_generator ' ),
515
520
new Reference (IdentifierGenerator::class),
@@ -530,7 +535,7 @@ public function executeOnly(string $routeServiceId, array $route, ContainerBuild
530
535
ExecuteOnly::class,
531
536
[
532
537
$ this ->generateWriteAction ($ routeServiceId . '.action ' , $ route ['command ' ], $ container ),
533
- new Reference (ResponseInterface ::class),
538
+ new Reference (ResponseFactoryInterface ::class),
534
539
$ route ['async ' ] === true ? StatusCode::STATUS_ACCEPTED : StatusCode::STATUS_NO_CONTENT ,
535
540
]
536
541
);
@@ -550,7 +555,7 @@ public function executeAndFetch(string $routeServiceId, array $route, ContainerB
550
555
[
551
556
$ this ->generateWriteAction ($ routeServiceId . '.action ' , $ route ['command ' ], $ container ),
552
557
$ this ->generateReadAction ($ routeServiceId . '.read_action ' , $ route ['query ' ], $ container ),
553
- new Reference (ResponseInterface ::class),
558
+ new Reference (ResponseFactoryInterface ::class),
554
559
]
555
560
);
556
561
0 commit comments