added a raw argument to the HttpKernel::handle() method
This commit is contained in:
parent
83c6d337e2
commit
9c2c992870
@ -55,12 +55,13 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
*
|
*
|
||||||
* @param Request $request A Request instance
|
* @param Request $request A Request instance
|
||||||
* @param Boolean $main Whether this is the main request or not
|
* @param Boolean $main Whether this is the main request or not
|
||||||
|
* @param Boolean $raw Whether to catch exceptions or not
|
||||||
*
|
*
|
||||||
* @return Response $response A Response instance
|
* @return Response $response A Response instance
|
||||||
*
|
*
|
||||||
* @throws \Exception When Exception couldn't be caught by event processing
|
* @throws \Exception When Exception couldn't be caught by event processing
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request = null, $main = true)
|
public function handle(Request $request = null, $main = true, $raw = false)
|
||||||
{
|
{
|
||||||
$main = (Boolean) $main;
|
$main = (Boolean) $main;
|
||||||
|
|
||||||
@ -80,6 +81,11 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
if (true === $raw)
|
||||||
|
{
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
// exception
|
// exception
|
||||||
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.exception', array('main_request' => $main, 'request' => $request, 'exception' => $e)));
|
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.exception', array('main_request' => $main, 'request' => $request, 'exception' => $e)));
|
||||||
if ($event->isProcessed())
|
if ($event->isProcessed())
|
||||||
@ -104,7 +110,7 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
* @throws \LogicException If one of the listener does not behave as expected
|
* @throws \LogicException If one of the listener does not behave as expected
|
||||||
* @throws NotFoundHttpException When controller cannot be found
|
* @throws NotFoundHttpException When controller cannot be found
|
||||||
*/
|
*/
|
||||||
public function handleRaw(Request $request, $main = true)
|
protected function handleRaw(Request $request, $main = true)
|
||||||
{
|
{
|
||||||
$main = (Boolean) $main;
|
$main = (Boolean) $main;
|
||||||
|
|
||||||
|
@ -25,12 +25,11 @@ interface HttpKernelInterface
|
|||||||
*
|
*
|
||||||
* @param Request $request A Request instance
|
* @param Request $request A Request instance
|
||||||
* @param Boolean $main Whether this is the main request or not
|
* @param Boolean $main Whether this is the main request or not
|
||||||
|
* @param Boolean $raw Whether to catch exceptions or not
|
||||||
*
|
*
|
||||||
* @return Response $response A Response instance
|
* @return Response $response A Response instance
|
||||||
*
|
|
||||||
* @throws \Exception When Exception couldn't be caught by event processing
|
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request = null, $main = true);
|
public function handle(Request $request = null, $main = true, $raw = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Request instance associated with the main request.
|
* Gets the Request instance associated with the main request.
|
||||||
|
@ -172,8 +172,6 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||||||
* @param Boolean $raw Whether to catch exceptions or not
|
* @param Boolean $raw Whether to catch exceptions or not
|
||||||
*
|
*
|
||||||
* @return Response $response A Response instance
|
* @return Response $response A Response instance
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request = null, $main = true, $raw = false)
|
public function handle(Request $request = null, $main = true, $raw = false)
|
||||||
{
|
{
|
||||||
@ -196,14 +194,7 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true === $raw)
|
return $this->container->getHttpKernelService()->handle($request, $main, $raw);
|
||||||
{
|
|
||||||
return $this->container->getHttpKernelService()->handleRaw($request, $main);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return $this->container->getHttpKernelService()->handle($request, $main);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBundleDirs()
|
public function getBundleDirs()
|
||||||
|
@ -497,14 +497,7 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true === $raw)
|
return $this->container->getHttpKernelService()->handle($request, $main, $raw);
|
||||||
{
|
|
||||||
return $this->container->getHttpKernelService()->handleRaw($request, $main);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return $this->container->getHttpKernelService()->handle($request, $main);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBundleDirs()
|
public function getBundleDirs()
|
||||||
|
@ -47,7 +47,7 @@ class ControllerLoader
|
|||||||
|
|
||||||
$subRequest = $request->duplicate($query, null, $path);
|
$subRequest = $request->duplicate($query, null, $path);
|
||||||
|
|
||||||
$response = $this->container->getHttpKernelService()->handleRaw($subRequest, false);
|
$response = $this->container->handle($subRequest, false, true);
|
||||||
|
|
||||||
$this->container->setService('request', $request);
|
$this->container->setService('request', $request);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class ExceptionHandler
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$response = $event->getSubject()->handleRaw($request, false);
|
$response = $event->getSubject()->handle($request, false, true);
|
||||||
|
|
||||||
error_log(sprintf('%s: %s', get_class($exception), $exception->getMessage()));
|
error_log(sprintf('%s: %s', get_class($exception), $exception->getMessage()));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user