Skip to content

Commit 8bbef67

Browse files
committed
symfony 2.8 bootstrap
symfony 2.8 loader symfony 2.8 app kernel loader fix bridge fix symfony2.8 for the win
1 parent fb0ed54 commit 8bbef67

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

Bootstraps/Symfony.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,28 @@ public function getStaticDirectory()
4545
*/
4646
public function getApplication()
4747
{
48-
49-
50-
5148
// include applications autoload
5249
$appAutoLoader = './app/autoload.php';
5350
if (file_exists($appAutoLoader)) {
5451
require $appAutoLoader;
55-
$app = new \AppKernel($this->appenv, $this->debug);
56-
} elseif(file_exists('./vendor/autoload.php')) {
52+
} elseif (file_exists('./vendor/autoload.php')) {
5753
require './vendor/autoload.php';
54+
}
55+
if(class_exists('\AppKernel')) {
5856
$app = new \AppKernel($this->appenv, $this->debug);
5957
} 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+
}
6363

64-
}
6564

65+
}
6666
//since we need to change some services, we need to manually change some services
67-
68-
6967
//we need to change some services, before the boot, because they would otherwise
7068
//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) {
7270
// init bundles
7371
$app->initializeBundles();
7472

@@ -79,12 +77,12 @@ public function getApplication()
7977
//now we can modify the container
8078
$nativeStorage = new StrongerNativeSessionStorage(
8179
$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,
8381
$app->getContainer()->get('session.storage.metadata_bag')
8482
);
8583
$app->getContainer()->set('session.storage.native', $nativeStorage);
8684

87-
Utils::bindAndCall(function() use ($app) {
85+
Utils::bindAndCall(function () use ($app) {
8886
foreach ($app->getBundles() as $bundle) {
8987
$bundle->setContainer($app->container);
9088
$bundle->boot();
@@ -131,7 +129,7 @@ public function postHandle($app)
131129
//->Twig_Loader_Filesystem
132130
if ($container->has('twig.loader')) {
133131
$twigLoader = $container->get('twig.loader');
134-
Utils::bindAndCall(function() use ($twigLoader) {
132+
Utils::bindAndCall(function () use ($twigLoader) {
135133
foreach ($twigLoader->cache as $path) {
136134
ppm_register_file($path);
137135
}
@@ -157,7 +155,7 @@ public function postHandle($app)
157155
if ($profiler->has('db')) {
158156
Utils::bindAndCall(function () {
159157
//$logger: \Doctrine\DBAL\Logging\DebugStack
160-
foreach ($this->loggers as $logger){
158+
foreach ($this->loggers as $logger) {
161159
Utils::hijackProperty($logger, 'queries', []);
162160
}
163161
}, $profiler->get('db'), null, 'Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector');

Bridges/HttpKernel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ protected function mapRequest(ReactRequest $reactRequest)
147147
$post = $reactRequest->getPost();
148148

149149
$class = $this->bootstrap->requestClass();
150-
150+
151+
SymfonyRequest::setTrustedProxies(array($_SERVER['REMOTE_ADDR']));
151152
$syRequest = new $class($query, $post, $attributes = [], $cookies, $files, $_SERVER, $reactRequest->getBody());
152153

153154
$syRequest->setMethod($method);

0 commit comments

Comments
 (0)