Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 38 additions & 17 deletions src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,42 +74,63 @@ public function forward($controller, array $path = array(), array $query = array
}

/**
* Returns an HTTP redirect Response.
* Returns an external HTTP redirect Response.
*
* @param string $url URL to redirect to
* @param int $status HTTP Status code
*
* @return Response A Response instance
*/
public function redirect($url, $status = 302)
public function redirectToUri($url, $status = 302)
{
$response = $this->container->get('response');
$response->setRedirect($url, $status);
return $response;
$view = $this->container->get('view');
$view->setUriRedirect($url, $status);
return $view->handle($this->container->get('request'));
}

/**
* Returns a rendered view.
* Returns an internal HTTP redirect Response.
*
* @param string $view The view name
* @param array $parameters An array of parameters to pass to the view
* @param string $route Route name
* @param array $parameters Route parameters
* @param int $status HTTP Status code
*
* @return string The renderer view
* @return Response A Response instance
*/
public function renderView($view, array $parameters = array())
public function redirectToRoute($route, array $parameters = array(), $status = 302)
{
return $this->container->get('templating')->render($view, $parameters);
$view = $this->container->get('view');
$view->setRouteRedirect($route, $parameters, $status);
return $view->handle($this->container->get('request'));
}

/**
* Renders a view.
* Handles the view layer
*
* @param string $view The view name
* @param array $parameters An array of parameters to pass to the view
* @param Response $response A response instance
* @param array $parameters An array of parameters to pass to the view
* @param string $template The view name
*
* @return Response A Response instance
*/
public function render($view, array $parameters = array(), Response $response = null)
public function handle(array $parameters = array(), $template = null)
{
return $this->container->get('templating')->renderResponse($view, $parameters, $response);
$view = $this->container->get('view');
$view->setParameters($parameters);
$view->setTemplate($template);
return $view->handle($this->container->get('request'));
}

/**
* Returns a rendered view.
*
* @param string $view The view name
* @param array $parameters An array of parameters to pass to the view
*
* @return string The renderer view
*/
public function renderView($view, array $parameters = array())
{
return $this->container->get('templating')->render($view, $parameters);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<parameter key="exception_listener.controller">Symfony\Bundle\FrameworkBundle\Controller\ExceptionController::exceptionAction</parameter>
<parameter key="esi.class">Symfony\Component\HttpKernel\Cache\Esi</parameter>
<parameter key="esi_listener.class">Symfony\Component\HttpKernel\Cache\EsiListener</parameter>
<parameter key="view.class">Symfony\Bundle\FrameworkBundle\View\DefaultView</parameter>
</parameters>

<services>
Expand Down Expand Up @@ -50,5 +51,9 @@
<argument>%exception_listener.controller%</argument>
<argument type="service" id="logger" on-invalid="null" />
</service>

<service id="view" class="%view.class%">
<argument type="service" id="service_container" />
</service>
</services>
</container>
Loading