2014-09-05 20:33:05 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru;
|
|
|
|
|
|
|
|
final class Injector
|
|
|
|
{
|
|
|
|
private static $container;
|
|
|
|
|
|
|
|
public static function init()
|
|
|
|
{
|
2014-09-06 17:51:04 +02:00
|
|
|
$definitionsPath = __DIR__
|
|
|
|
. DIRECTORY_SEPARATOR . '..'
|
|
|
|
. DIRECTORY_SEPARATOR . 'src'
|
|
|
|
. DIRECTORY_SEPARATOR . 'di.php';
|
|
|
|
|
2014-09-05 20:33:05 +02:00
|
|
|
$builder = new \DI\ContainerBuilder();
|
|
|
|
$builder->setDefinitionCache(new \Doctrine\Common\Cache\ArrayCache());
|
2014-09-06 17:51:04 +02:00
|
|
|
$builder->addDefinitions($definitionsPath);
|
2014-09-05 20:33:05 +02:00
|
|
|
self::$container = $builder->build();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function get($className)
|
|
|
|
{
|
|
|
|
return self::$container->get($className);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Injector::init();
|