Skip to content

Commit

Permalink
Use ContainerInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Sep 9, 2019
1 parent c200523 commit fdadc22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"php": "^7.1",
"fig/http-message-util": "^1.1",
"league/container": "^3.3",
"league/plates": "^3.3",
"monolog/monolog": "^1.24",
"odan/csrf": "^3.0",
"odan/plates-asset-cache": "^2.0",
"odan/twig-assets": "^2.1",
"odan/twig-translation": "^1.3",
"psr/log": "^1.1",
Expand Down
14 changes: 7 additions & 7 deletions config/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$container->delegate(new ReflectionContainer());

// The container
$container->share(ContainerInterface::class, static function (Container $container) {
$container->share(ContainerInterface::class, static function (ContainerInterface $container) {
return $container;
})->addArgument($container);

Expand All @@ -37,7 +37,7 @@
});

// Slim App
$container->share(App::class, static function (Container $container) {
$container->share(App::class, static function (ContainerInterface $container) {
AppFactory::setContainer($container);
$app = AppFactory::create();

Expand All @@ -55,12 +55,12 @@
});

// The Slim RouterParser
$container->share(RouteParserInterface::class, static function (Container $container) {
$container->share(RouteParserInterface::class, static function (ContainerInterface $container) {
return $container->get(App::class)->getRouteCollector()->getRouteParser();
})->addArgument($container);

// The logger
$container->share(LoggerInterface::class, static function (Container $container) {
$container->share(LoggerInterface::class, static function (ContainerInterface $container) {
$settings = $container->get('settings')['logger'];
$logger = new Logger($settings['name']);

Expand All @@ -74,7 +74,7 @@
})->addArgument($container);

// Twig templates
$container->share(Twig::class, static function (Container $container) {
$container->share(Twig::class, static function (ContainerInterface $container) {
$settings = $container->get('settings');
$viewPath = $settings['twig']['path'];

Expand Down Expand Up @@ -105,7 +105,7 @@
})->addArgument($container);

// Translation
$container->share(Translator::class, static function (Container $container) {
$container->share(Translator::class, static function (ContainerInterface $container) {
$settings = $container->get('settings')['locale'];

$translator = new Translator(
Expand All @@ -123,7 +123,7 @@
return $translator;
})->addArgument($container);

$container->share(TranslatorMiddleware::class, static function (Container $container) {
$container->share(TranslatorMiddleware::class, static function (ContainerInterface $container) {
$settings = $container->get('settings')['locale'];
$localPath = $settings['path'];
$translator = $container->get(Translator::class);
Expand Down

0 comments on commit fdadc22

Please sign in to comment.