fixed Client when using the terminable event

This commit is contained in:
Fabien Potencier 2013-09-29 21:03:21 +02:00
parent a46ff2fc59
commit 8c8cf62038
2 changed files with 22 additions and 4 deletions

View File

@ -156,7 +156,7 @@ class Client extends BaseClient
$profilerCode = '$kernel->getContainer()->get(\'profiler\')->enable();';
}
return <<<EOF
$code = <<<EOF
<?php
if ('$autoloader') {
@ -167,7 +167,10 @@ require_once '$path';
\$kernel = unserialize('$kernel');
\$kernel->boot();
$profilerCode
echo serialize(\$kernel->handle(unserialize('$request')));
\$request = unserialize('$request');
EOF;
return $code.$this->getHandleScript();
}
}

View File

@ -84,7 +84,7 @@ class Client extends BaseClient
$requirePath = str_replace("'", "\\'", $r->getFileName());
$symfonyPath = str_replace("'", "\\'", realpath(__DIR__.'/../../..'));
return <<<EOF
$code = <<<EOF
<?php
require_once '$requirePath';
@ -94,7 +94,22 @@ require_once '$requirePath';
\$loader->register();
\$kernel = unserialize('$kernel');
echo serialize(\$kernel->handle(unserialize('$request')));
\$request = unserialize('$request');
EOF;
return $code.$this->getHandleScript();
}
protected function getHandleScript()
{
return <<<'EOF'
$response = $kernel->handle($request);
if ($kernel instanceof Symfony\Component\HttpKernel\TerminableInterface) {
$kernel->terminate($request, $response);
}
echo serialize($response);
EOF;
}