33namespace App ;
44
55use App \Container \Container ;
6+ use App \Container \ContainerCreator ;
67use App \Database \Database ;
78use App \Middleware \ExampleMiddleware ;
89use App \Handlers \HttpErrorHandler ;
910use App \Handlers \ShutdownHandler ;
1011use Psr \Http \Message \ResponseInterface ;
1112use Psr \Http \Message \ServerRequestInterface ;
1213use Slim \App as SlimApp ;
13- use Slim \ Factory \ AppFactory ;
14+ use DI \ Bridge \ Slim \ Bridge as AppFactory ;
1415use Slim \Factory \ServerRequestCreatorFactory ;
1516
1617class App
@@ -21,9 +22,9 @@ class App
2122 public $ dev_mode ;
2223
2324 /**
24- * @var Container
25+ * @var ContainerCreator
2526 */
26- protected $ container ;
27+ protected $ container_creator ;
2728
2829 /**
2930 * @var SlimApp
@@ -47,10 +48,10 @@ public function __construct()
4748 {
4849 $ this ->dev_mode = $ this ->isDevelopmentMode ();
4950
50- $ this ->container = new Container ($ this );
51- $ this ->slim = AppFactory::createFromContainer ($ this ->container ()-> get ());
51+ $ this ->container_creator = new ContainerCreator ($ this );
52+ $ this ->slim = AppFactory::create ($ this ->container ());
5253
53- $ this ->container () ->setup ();
54+ $ this ->container_creator ->setup ();
5455 $ this ->setupSlim ();
5556
5657 $ this ->database = new Database ();
@@ -69,11 +70,11 @@ public function isDevelopmentMode(): bool
6970 /**
7071 * Get the container
7172 *
72- * @return Container
73+ * @return \DI\ Container
7374 */
74- public function container (): Container
75+ public function container (): \ DI \ Container
7576 {
76- return $ this ->container ;
77+ return $ this ->container_creator -> container () ;
7778 }
7879
7980 /**
@@ -97,7 +98,7 @@ protected function addMiddleware(): void
9798 ->addErrorMiddleware ($ this ->dev_mode , false , false )
9899 ->setDefaultErrorHandler ($ this ->error_handler );
99100
100- $ this ->slim ()->add ('csrf ' );
101+ $ this ->slim ()->add ($ this -> container ()-> get ( 'csrf ' ) );
101102 // $this->slim()->add(ExampleMiddleware::class);
102103 }
103104
@@ -115,7 +116,7 @@ protected function addRoutes(): void
115116 protected function addErrorHandler (): void
116117 {
117118 $ this ->error_handler = new HttpErrorHandler (
118- $ this ->container ()-> get () ,
119+ $ this ->container (),
119120 $ this ->slim ()->getCallableResolver (),
120121 $ this ->slim ()->getResponseFactory ()
121122 );
0 commit comments