diff --git a/app/src/Bootstrap.php b/app/src/Bootstrap.php index 5ef7885..ec26019 100644 --- a/app/src/Bootstrap.php +++ b/app/src/Bootstrap.php @@ -32,6 +32,8 @@ use Psr\Log\LoggerInterface; use Slim\App; use Slim\Factory\AppFactory; use Slim\Psr7\Factory\ResponseFactory; +use Slovocast\Infrastructure\Application\LoggerDefinition; +use Slovocast\Infrastructure\Application\SessionDefintion; use Slovocast\Middleware\SessionMiddleware; use Twig\Error\LoaderError; @@ -126,36 +128,12 @@ class Bootstrap /** * Global logging */ - LoggerInterface::class => function() { - $logger = new Logger("default"); - $logger->pushHandler(new StreamHandler('php://stdout', Level::Info)); - return $logger; - }, + (new LoggerDefinition())->define(), /** * Session and Flash classes here */ - SessionManagerInterface::class => function (ContainerInterface $container) { - return $container->get(SessionInterface::class); - }, - SessionInterface::class => function (ContainerInterface $container) { - $options = $container->get('config')->get('session'); - return new PhpSession($options); - }, - 'session' => function (ContainerInterface $container) { - return $container->get(SessionInterface::class); - }, - SessionMiddleware::class => function (ContainerInterface $container) { - return new SessionMiddleware( - $container->get(SessionManagerInterface::class), - $container->get(SessionInterface::class), - $container->get(LoggerInterface::class) - ); - }, - - UserSessionManagerInterface::class => function (ContainerInterface $container) { - return new UserSessionManager($container->get(SessionInterface::class)); - }, + (new SessionDefintion())->define(), /** * Application DI diff --git a/app/src/Infrastructure/Application/SessionDefinition.php b/app/src/Infrastructure/Application/SessionDefinition.php new file mode 100644 index 0000000..cdd6c73 --- /dev/null +++ b/app/src/Infrastructure/Application/SessionDefinition.php @@ -0,0 +1,42 @@ + function (ContainerInterface $container) { + return $container->get(SessionInterface::class); + }, + SessionInterface::class => function (ContainerInterface $container) { + $options = $container->get('config')->get('session'); + return new PhpSession($options); + }, + 'session' => function (ContainerInterface $container) { + return $container->get(SessionInterface::class); + }, + SessionMiddleware::class => function (ContainerInterface $container) { + return new SessionMiddleware( + $container->get(SessionManagerInterface::class), + $container->get(SessionInterface::class), + $container->get(LoggerInterface::class) + ); + }, + UserSessionManagerInterface::class => function (ContainerInterface $container) { + return new UserSessionManager($container->get(SessionInterface::class)); + }, + ]; + } +}