added ControllerResolver::forward() (will probably move it elsewhere later on)

This commit is contained in:
Fabien Potencier 2010-08-14 20:36:09 +02:00
parent 75ea0b8395
commit 38edd2aafa
2 changed files with 18 additions and 5 deletions

View File

@ -5,7 +5,6 @@ namespace Symfony\Bundle\FrameworkBundle;
use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\HttpFoundation\Request;
use Symfony\Components\HttpFoundation\Response;
use Symfony\Components\HttpKernel\HttpKernelInterface;
/*
* This file is part of the Symfony framework.
@ -93,10 +92,7 @@ class Controller
*/
public function forward($controller, array $path = array(), array $query = array())
{
$path['_controller'] = $controller;
$subRequest = $this->getRequest()->duplicate($query, null, $path);
return $this->container->get('kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
return $this->container->get('controller_resolver')->forward($controller, $path, $query);
}
/**

View File

@ -69,6 +69,23 @@ class ControllerResolver extends BaseControllerResolver
return array(new $class($this->container), $method);
}
/**
* Forwards the request to another controller.
*
* @param string $controller The controller name (a string like BlogBundle:Post:index)
* @param array $path An array of path parameters
* @param array $query An array of query parameters
*
* @return Response A Response instance
*/
public function forward($controller, array $path = array(), array $query = array())
{
$path['_controller'] = $controller;
$subRequest = $this->getRequest()->duplicate($query, null, $path);
return $this->container->get('kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
/**
* Renders a Controller and returns the Response content.
*