HummingBirdAnimeClient/tests/Ion/di.php

38 lines
1.2 KiB
PHP
Raw Permalink Normal View History

<?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};
// -----------------------------------------------------------------------------
// Setup DI container
// -----------------------------------------------------------------------------
2022-03-04 12:19:47 -05:00
return static function (array $config_array = []) {
$container = new Container();
2022-03-04 12:19:47 -05:00
$container->set('config', static fn () => new Config([]));
$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
));
2022-03-04 12:19:47 -05:00
$container->set('response', static fn () => new Response());
// Create session Object
2022-03-04 12:19:47 -05:00
$container->set('session', static fn () => (new SessionFactory())->newInstance($_COOKIE));
// 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());
return $container;
2022-03-04 12:19:47 -05:00
};