2017-03-20 13:41:48 -04:00
|
|
|
<?php declare(strict_types=1);
|
2016-08-04 14:55:37 -04:00
|
|
|
|
|
|
|
use Aura\Html\HelperLocatorFactory;
|
|
|
|
use Aura\Session\SessionFactory;
|
|
|
|
use Zend\Diactoros\ServerRequestFactory;
|
|
|
|
use Zend\Diactoros\Response;
|
|
|
|
|
|
|
|
use Aviat\Ion\Config;
|
|
|
|
use Aviat\Ion\Di\Container;
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Setup DI container
|
|
|
|
// -----------------------------------------------------------------------------
|
2019-12-05 16:20:10 -05:00
|
|
|
return static function(array $config_array = []) {
|
2016-08-29 12:51:40 -04:00
|
|
|
$container = new Container();
|
|
|
|
|
2019-12-05 16:20:10 -05:00
|
|
|
$container->set('config', static function() {
|
2016-08-29 12:51:40 -04:00
|
|
|
return new Config([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$container->setInstance('config', new Config($config_array));
|
|
|
|
|
2019-12-05 16:20:10 -05:00
|
|
|
$container->set('request', static function() {
|
2016-08-29 12:51:40 -04:00
|
|
|
return ServerRequestFactory::fromGlobals(
|
|
|
|
$_SERVER,
|
|
|
|
$_GET,
|
|
|
|
$_POST,
|
|
|
|
$_COOKIE,
|
|
|
|
$_FILES
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2019-12-05 16:20:10 -05:00
|
|
|
$container->set('response', static function() {
|
2016-08-29 12:51:40 -04:00
|
|
|
return new Response();
|
|
|
|
});
|
2016-08-04 14:55:37 -04:00
|
|
|
|
|
|
|
// Create session Object
|
2019-12-05 16:20:10 -05:00
|
|
|
$container->set('session', static function() {
|
2016-08-04 14:55:37 -04:00
|
|
|
return (new SessionFactory())->newInstance($_COOKIE);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create Html helper Object
|
2019-12-05 16:20:10 -05:00
|
|
|
$container->set('html-helper', static function() {
|
2016-08-04 14:55:37 -04:00
|
|
|
return (new HelperLocatorFactory)->newInstance();
|
|
|
|
});
|
|
|
|
|
|
|
|
return $container;
|
|
|
|
};
|