mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Added Injector class
This commit is contained in:
@ -5,9 +5,5 @@ define('DS', DIRECTORY_SEPARATOR);
|
|||||||
require_once(__DIR__ . DS . '..' . DS . 'vendor' . DS . 'autoload.php');
|
require_once(__DIR__ . DS . '..' . DS . 'vendor' . DS . 'autoload.php');
|
||||||
require_once(__DIR__ . DS . '..' . DS . 'src' . DS . 'AutoLoader.php');
|
require_once(__DIR__ . DS . '..' . DS . 'src' . DS . 'AutoLoader.php');
|
||||||
|
|
||||||
$builder = new \DI\ContainerBuilder();
|
$dispatcher = \Szurubooru\Injector::get(\Szurubooru\Dispatcher::class);
|
||||||
$builder->setDefinitionCache(new Doctrine\Common\Cache\ArrayCache());
|
|
||||||
$builder->addDefinitions(__DIR__ . DS . '..' . DS . 'src' . DS . 'di.php');
|
|
||||||
$container = $builder->build();
|
|
||||||
$dispatcher = $container->get('Szurubooru\Dispatcher');
|
|
||||||
$dispatcher->run();
|
$dispatcher->run();
|
||||||
|
22
src/Injector.php
Normal file
22
src/Injector.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
namespace Szurubooru;
|
||||||
|
|
||||||
|
final class Injector
|
||||||
|
{
|
||||||
|
private static $container;
|
||||||
|
|
||||||
|
public static function init()
|
||||||
|
{
|
||||||
|
$builder = new \DI\ContainerBuilder();
|
||||||
|
$builder->setDefinitionCache(new \Doctrine\Common\Cache\ArrayCache());
|
||||||
|
$builder->addDefinitions(__DIR__ . DS . '..' . DS . 'src' . DS . 'di.php');
|
||||||
|
self::$container = $builder->build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get($className)
|
||||||
|
{
|
||||||
|
return self::$container->get($className);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Injector::init();
|
Reference in New Issue
Block a user