12
12
use Doctrine \Common \Cache \ApcCache ;
13
13
use Doctrine \Common \Cache \FilesystemCache ;
14
14
use BEAR \Package \Module \Di \DiCompilerProvider ;
15
- use Ray \Aop \Matcher ;
16
- use Ray \Di \AbstractModule ;
17
- use Ray \Di \Injector ;
18
- use Ray \Di \CacheableModule ;
19
15
use Doctrine \Common \Cache \Cache ;
20
- use Ray \Di \CacheInjector ;
21
- use Ray \Di \ModuleCacheInjector ;
22
16
23
- class Bootstrap
17
+ final class Bootstrap
24
18
{
25
19
/**
26
20
* @param ClassLoader $loader
@@ -37,26 +31,6 @@ public static function registerLoader(ClassLoader $loader, $appName, $appDir)
37
31
AnnotationReader::addGlobalIgnoredName ('returns ' );
38
32
}
39
33
40
- /**
41
- * Return compiled application instance
42
- *
43
- * (experimental)
44
- *
45
- * @param $appName
46
- * @param $context
47
- * @param $tmpDir
48
- *
49
- * @return \BEAR\Sunday\Extension\Application\AppInterface
50
- */
51
- public static function getCompiledApp ($ appName , $ context , $ tmpDir , Cache $ cache = null )
52
- {
53
- $ diCompiler = (new DiCompilerProvider ($ appName , $ context , $ tmpDir , $ cache ))->get ();
54
- $ app = $ diCompiler ->getInstance ('BEAR\Sunday\Extension\Application\AppInterface ' );
55
- /** $app \BEAR\Sunday\Extension\Application\AppInterface */
56
-
57
- return $ app ;
58
- }
59
-
60
34
/**
61
35
* @param string $appName
62
36
* @param string $context
@@ -67,44 +41,10 @@ public static function getCompiledApp($appName, $context, $tmpDir, Cache $cache
67
41
*/
68
42
public static function getApp ($ appName , $ context , $ tmpDir , Cache $ cache = null )
69
43
{
70
- $ appModule = $ appName . '\Module\AppModule ' ;
71
- $ cache = $ cache ?: (function_exists ('apc_fetch ' ) ? new ApcCache : new FilesystemCache ($ tmpDir ));
72
- $ cacheKey = 'module- ' . $ appName . $ context ;
73
- $ moduleProvider = function () use ($ appModule , $ context ) {return new $ appModule ($ context );};
74
- $ injector = ModuleCacheInjector::create ($ moduleProvider , $ cache , $ cacheKey , $ tmpDir );
75
- $ app = $ injector ->getInstance ('BEAR\Sunday\Extension\Application\AppInterface ' );
76
-
44
+ $ diCompiler = (new DiCompilerProvider ($ appName , $ context , $ tmpDir , $ cache ))->get ();
45
+ $ app = $ diCompiler ->getInstance ('BEAR\Sunday\Extension\Application\AppInterface ' );
77
46
/** $app \BEAR\Sunday\Extension\Application\AppInterface */
78
- return $ app ;
79
- }
80
47
81
- /**
82
- * Return cached application instance
83
- *
84
- * (experimental)
85
- *
86
- * @param string $appName
87
- * @param string $context
88
- * @param string $tmpDir
89
- * @param Cache $cache
90
- *
91
- * @return \BEAR\Sunday\Extension\Application\AppInterface
92
- */
93
- public static function getCachedApp ($ appName , $ context , $ tmpDir , Cache $ cache = null )
94
- {
95
- $ appModule = $ appName . '\Module\AppModule ' ;
96
- $ cache = $ cache ?: function_exists ('apc_fetch ' ) ? new ApcCache : new FilesystemCache ($ tmpDir );
97
- $ cacheKey = $ appName . $ context ;
98
- $ initialization = function () {
99
- // initialize per system startup (not per each request)
100
- };
101
- $ injector = function () use ($ appModule , $ cache ) {
102
- return Injector::create ([new $ appModule ], $ cache , __DIR__ . '/tmp ' );
103
- };
104
- $ injector = new CacheInjector ($ injector , $ initialization , $ cacheKey , $ cache );
105
- $ app = $ injector ->getInstance ('BEAR\Sunday\Extension\Application\AppInterface ' );
106
-
107
- /** $app \BEAR\Sunday\Extension\Application\AppInterface */
108
48
return $ app ;
109
49
}
110
50
0 commit comments