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