1 | <?php |
||
19 | class Bootstrap |
||
20 | { |
||
21 | protected static $serviceManager; |
||
22 | |||
23 | public static function init() |
||
24 | { |
||
25 | $zf2ModulePaths = [dirname(dirname(__DIR__))]; |
||
26 | if (($path = static::findParentPath('vendor'))) { |
||
27 | $zf2ModulePaths[] = $path; |
||
28 | } |
||
29 | if (($path = static::findParentPath('module')) !== $zf2ModulePaths[0]) { |
||
30 | $zf2ModulePaths[] = $path; |
||
31 | } |
||
32 | |||
33 | static::initAutoloader(); |
||
34 | |||
35 | // use ModuleManager to load this module and it's dependencies |
||
36 | if (file_exists(__DIR__ . '/TestConfiguration.php')) { |
||
37 | $config = require __DIR__ . '/../TestConfiguration.php'; |
||
38 | } else { |
||
39 | $config = require __DIR__ . '/../TestConfiguration.php.dist'; |
||
40 | } |
||
41 | |||
42 | $smConfig = new ServiceManagerConfig(); |
||
43 | $serviceManager = new ServiceManager(); |
||
44 | $smConfig->configureServiceManager($serviceManager); |
||
45 | $serviceManager->setService('ApplicationConfig', $config); |
||
46 | $serviceManager->get('ModuleManager')->loadModules(); |
||
47 | |||
48 | $application = new Application($config, $serviceManager); |
||
49 | $application->bootstrap(); |
||
50 | |||
51 | static::$serviceManager = $serviceManager; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return ServiceManager |
||
56 | */ |
||
57 | public static function getServiceManager() |
||
61 | |||
62 | protected static function initAutoloader() |
||
70 | |||
71 | protected static function findParentPath($path) |
||
84 | } |
||
85 |