Browse Source

[Foundation] added a way to call RequestHandler::handleRaw() from the Kernel

Fabien Potencier 15 years ago
parent
commit
bdbb02d7b9
2 changed files with 30 additions and 4 deletions
  1. 20 2
      src/Symfony/Foundation/Kernel.php
  2. 10 2
      src/Symfony/Foundation/bootstrap.php

+ 20 - 2
src/Symfony/Foundation/Kernel.php

@@ -164,7 +164,18 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable
     return $this->request;
   }
 
-  public function handle(Request $request = null, $main = true)
+  /**
+   * Handles a request to convert it to a response by calling the Request Handler service.
+   *
+   * @param  Request $request A Request instance
+   * @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
+   *
+   * @throws \Exception
+   */
+  public function handle(Request $request = null, $main = true, $raw = false)
   {
     if (false === $this->booted)
     {
@@ -185,7 +196,14 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable
       $this->request = $request;
     }
 
-    return $this->container->getRequestHandlerService()->handle($request);
+    if (true === $raw)
+    {
+      return $this->container->getRequestHandlerService()->handleRaw($request, $main);
+    }
+    else
+    {
+      return $this->container->getRequestHandlerService()->handle($request, $main);
+    }
   }
 
   public function getBundleDirs()

+ 10 - 2
src/Symfony/Foundation/bootstrap.php

@@ -475,7 +475,8 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable
     return $this->request;
   }
 
-  public function handle(Request $request = null, $main = true)
+  
+  public function handle(Request $request = null, $main = true, $raw = false)
   {
     if (false === $this->booted)
     {
@@ -496,7 +497,14 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable
       $this->request = $request;
     }
 
-    return $this->container->getRequestHandlerService()->handle($request);
+    if (true === $raw)
+    {
+      return $this->container->getRequestHandlerService()->handleRaw($request, $main);
+    }
+    else
+    {
+      return $this->container->getRequestHandlerService()->handle($request, $main);
+    }
   }
 
   public function getBundleDirs()