Permalink
Switch branches/tags
Find file Copy path
3d06bbe Mar 5, 2016
1 contributor

Users who have contributed to this file

47 lines (36 sloc) 1.54 KB
<?php
// DIC configuration
$container = $app->getContainer();
// -----------------------------------------------------------------------------
// Service providers
// -----------------------------------------------------------------------------
// Twig
$container['view'] = function ($c) {
$settings = $c->get('settings');
$view = new Slim\Views\Twig($settings['view']['template_path'], $settings['view']['twig']);
// Add extensions
$view->addExtension(new Slim\Views\TwigExtension($c->get('router'), $c->get('request')->getUri()));
$view->addExtension(new Twig_Extension_Debug());
return $view;
};
// Flash messages
$container['flash'] = function ($c) {
return new Slim\Flash\Messages;
};
// -----------------------------------------------------------------------------
// Service factories
// -----------------------------------------------------------------------------
// monolog
$container['logger'] = function ($c) {
$settings = $c->get('settings');
$logger = new Monolog\Logger($settings['logger']['name']);
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
$logger->pushHandler(new Monolog\Handler\StreamHandler($settings['logger']['path'], Monolog\Logger::DEBUG));
return $logger;
};
// -----------------------------------------------------------------------------
// Action factories
// -----------------------------------------------------------------------------
$container[App\Action\HomeAction::class] = function ($c) {
return new App\Action\HomeAction($c->get('view'), $c->get('logger'));
};