szurubooru/src/Injector.php

37 lines
775 B
PHP
Raw Normal View History

2014-09-05 20:33:05 +02:00
<?php
namespace Szurubooru;
use DI\ContainerBuilder;
use Doctrine\Common\Cache\ArrayCache;
2014-09-05 20:33:05 +02:00
final class Injector
{
private static $container;
public static function init()
{
$definitionsPath = __DIR__
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR . 'src'
. DIRECTORY_SEPARATOR . 'di.php';
$builder = new ContainerBuilder();
$builder->setDefinitionCache(new ArrayCache());
$builder->addDefinitions($definitionsPath);
2014-10-08 23:01:25 +02:00
$builder->useAutowiring(true);
$builder->useAnnotations(false);
2014-09-05 20:33:05 +02:00
self::$container = $builder->build();
}
public static function get($className)
{
return self::$container->get($className);
}
public static function set($className, $object)
{
return self::$container->set($className, $object);
}
2014-09-05 20:33:05 +02:00
}
Injector::init();