@@ -45,30 +45,28 @@ public function getStaticDirectory()
45
45
*/
46
46
public function getApplication ()
47
47
{
48
-
49
-
50
-
51
48
// include applications autoload
52
49
$ appAutoLoader = './app/autoload.php ' ;
53
50
if (file_exists ($ appAutoLoader )) {
54
51
require $ appAutoLoader ;
55
- $ app = new \AppKernel ($ this ->appenv , $ this ->debug );
56
- } elseif (file_exists ('./vendor/autoload.php ' )) {
52
+ } elseif (file_exists ('./vendor/autoload.php ' )) {
57
53
require './vendor/autoload.php ' ;
54
+ }
55
+ if (class_exists ('\AppKernel ' )) {
58
56
$ app = new \AppKernel ($ this ->appenv , $ this ->debug );
59
57
} else {
60
- $ loader = require_once __DIR__ .'./app/bootstrap.php.cache ' ;
61
- require_once __DIR__ .'/../app/AppKernel.php ' ;
62
- $ kernel = new AppKernel ('prod ' , false );
58
+ if (file_exists ('./app/bootstrap.php.cache ' ) && file_exists ('./app/AppKernel.php ' )) {
59
+ require_once './app/bootstrap.php.cache ' ;
60
+ require_once './app/AppKernel.php ' ;
61
+ $ app = new \AppKernel ($ this ->appenv , $ this ->debug );
62
+ }
63
63
64
- }
65
64
65
+ }
66
66
//since we need to change some services, we need to manually change some services
67
-
68
-
69
67
//we need to change some services, before the boot, because they would otherwise
70
68
//be instantiated and passed to other classes which makes it impossible to replace them.
71
- Utils::bindAndCall (function () use ($ app ) {
69
+ Utils::bindAndCall (function () use ($ app ) {
72
70
// init bundles
73
71
$ app ->initializeBundles ();
74
72
@@ -79,12 +77,12 @@ public function getApplication()
79
77
//now we can modify the container
80
78
$ nativeStorage = new StrongerNativeSessionStorage (
81
79
$ app ->getContainer ()->getParameter ('session.storage.options ' ),
82
- $ app ->getContainer ()->has ('session.handler ' ) ? $ app ->getContainer ()->get ('session.handler ' ): null ,
80
+ $ app ->getContainer ()->has ('session.handler ' ) ? $ app ->getContainer ()->get ('session.handler ' ) : null ,
83
81
$ app ->getContainer ()->get ('session.storage.metadata_bag ' )
84
82
);
85
83
$ app ->getContainer ()->set ('session.storage.native ' , $ nativeStorage );
86
84
87
- Utils::bindAndCall (function () use ($ app ) {
85
+ Utils::bindAndCall (function () use ($ app ) {
88
86
foreach ($ app ->getBundles () as $ bundle ) {
89
87
$ bundle ->setContainer ($ app ->container );
90
88
$ bundle ->boot ();
@@ -131,7 +129,7 @@ public function postHandle($app)
131
129
//->Twig_Loader_Filesystem
132
130
if ($ container ->has ('twig.loader ' )) {
133
131
$ twigLoader = $ container ->get ('twig.loader ' );
134
- Utils::bindAndCall (function () use ($ twigLoader ) {
132
+ Utils::bindAndCall (function () use ($ twigLoader ) {
135
133
foreach ($ twigLoader ->cache as $ path ) {
136
134
ppm_register_file ($ path );
137
135
}
@@ -157,7 +155,7 @@ public function postHandle($app)
157
155
if ($ profiler ->has ('db ' )) {
158
156
Utils::bindAndCall (function () {
159
157
//$logger: \Doctrine\DBAL\Logging\DebugStack
160
- foreach ($ this ->loggers as $ logger ){
158
+ foreach ($ this ->loggers as $ logger ) {
161
159
Utils::hijackProperty ($ logger , 'queries ' , []);
162
160
}
163
161
}, $ profiler ->get ('db ' ), null , 'Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector ' );
0 commit comments