Skip to content

Commit

Permalink
re-organized the sub-request management a bit (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 13, 2010
1 parent fd331ba commit 72947d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
12 changes: 8 additions & 4 deletions src/Symfony/Foundation/Kernel.php
Expand Up @@ -161,7 +161,7 @@ public function getRequest()
}

/**
* Handles a request to convert it to a response by calling the Request Handler service.
* Handles a request to convert it to a response by calling the HttpKernel service.
*
* @param Request $request A Request instance
* @param Boolean $main Whether this is the main request or not
Expand All @@ -177,15 +177,19 @@ public function handle(Request $request = null, $main = true, $raw = false)

if (null === $request) {
$request = $this->container->getRequestService();
} else {
$this->container->setService('request', $request);
}

if (true === $main) {
$this->request = $request;
}

return $this->container->getHttpKernelService()->handle($request, $main, $raw);
$this->container->setService('request', $request);

$response = $this->container->getHttpKernelService()->handle($request, $main, $raw);

$this->container->setService('request', $this->request);

return $response;
}

public function getBundleDirs()
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Framework/WebBundle/Controller.php
Expand Up @@ -82,9 +82,9 @@ public function generateUrl($route, array $parameters = array(), $absolute = fal
return $this->container->getRouterService()->generate($route, $parameters);
}

public function forward($controller, array $parameters = array())
public function forward($controller, array $path = array(), array $query = array())
{
return $this->container->getControllerLoaderService()->run($controller, $parameters);
return $this->container->getControllerLoaderService()->run($controller, $path, $query);
}

/**
Expand Down
10 changes: 2 additions & 8 deletions src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php
Expand Up @@ -41,17 +41,11 @@ public function register()

public function run($controller, array $path = array(), array $query = array())
{
$request = $this->container->getRequestService();

$path['_controller'] = $controller;

$subRequest = $request->duplicate($query, null, $path);

$response = $this->container->getKernelService()->handle($subRequest, false, true);

$this->container->setService('request', $request);
$subRequest = $this->container->getRequestService()->duplicate($query, null, $path);

return $response;
return $this->container->getKernelService()->handle($subRequest, false, true);
}

public function resolve(Event $event)
Expand Down

0 comments on commit 72947d8

Please sign in to comment.