Exemple #1
0
        $serviceManager->setService('Configuration', $cfg);
        $serviceManager->setAlias('Config', 'Configuration');
        static::$serviceManager = $serviceManager;
    }
    public static function getServiceManager()
    {
        return static::$serviceManager;
    }
    protected static function initAutoloader()
    {
        $vendorPath = static::findParentPath('vendor');
        if (file_exists($vendorPath . '/autoload.php')) {
            include $vendorPath . '/autoload.php';
        }
    }
    protected static function findParentPath($path)
    {
        $dir = __DIR__;
        $previousDir = '.';
        while (!is_dir($dir . '/' . $path)) {
            $dir = dirname($dir);
            if ($previousDir === $dir) {
                return false;
            }
            $previousDir = $dir;
        }
        return $dir . '/' . $path;
    }
}
Bootstrap::init();
Exemple #2
0
 /**
  * @dataProvider provideServiceList
  */
 public function testService($service)
 {
     $sm = Bootstrap::getServiceManager();
     $this->assertTrue($sm->has($service));
     $this->assertInstanceOf($service, $sm->get($service));
 }