2020-03-11 23:04:01 -04:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
use Aura\Html\HelperLocatorFactory;
|
|
|
|
use Aura\Session\SessionFactory;
|
2020-03-12 09:52:45 -04:00
|
|
|
use Laminas\Diactoros\ServerRequestFactory;
|
|
|
|
use Laminas\Diactoros\Response;
|
2020-03-11 23:04:01 -04:00
|
|
|
|
|
|
|
use Aviat\Ion\Config;
|
|
|
|
use Aviat\Ion\Di\Container;
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Setup DI container
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
return static function(array $config_array = []) {
|
|
|
|
$container = new Container();
|
|
|
|
|
|
|
|
$container->set('config', static function() {
|
|
|
|
return new Config([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$container->setInstance('config', new Config($config_array));
|
|
|
|
|
|
|
|
$container->set('request', static function() {
|
|
|
|
return ServerRequestFactory::fromGlobals(
|
|
|
|
$_SERVER,
|
|
|
|
$_GET,
|
|
|
|
$_POST,
|
|
|
|
$_COOKIE,
|
|
|
|
$_FILES
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
$container->set('response', static function() {
|
|
|
|
return new Response();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create session Object
|
|
|
|
$container->set('session', static function() {
|
|
|
|
return (new SessionFactory())->newInstance($_COOKIE);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create Html helper Object
|
2020-08-21 13:07:00 -04:00
|
|
|
$container->set('html-helper', fn() => (new HelperLocatorFactory)->newInstance());
|
|
|
|
$container->set('component-helper', fn() => (new HelperLocatorFactory)->newInstance());
|
2020-03-11 23:04:01 -04:00
|
|
|
|
|
|
|
return $container;
|
|
|
|
};
|