Symfony\Bundle\FrameworkBundle\HttpKernel::forward PHP Method

forward() public method

Forwards the request to another controller.
public forward ( string $controller, array $attributes = [], array $query = [] ) : Response
$controller string The controller name (a string like BlogBundle:Post:index)
$attributes array An array of request attributes
$query array An array of request query parameters
return Response A Response instance
    public function forward($controller, array $attributes = array(), array $query = array())
    {
        $attributes['_controller'] = $controller;
        $subRequest = $this->container->get('request')->duplicate($query, null, $attributes);

        return $this->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
    }

Usage Example

 /**
  * @param Request $request
  * @param null|AuthenticationException $authException
  * @return Response
  */
 public function start(Request $request, AuthenticationException $authException = null)
 {
     $action = $this->config['login_action'];
     $manager = $this->factory->getManager($this->config['manager'], $request->getUriForPath($this->config['check_path']));
     if ($action) {
         return $this->httpKernel->forward($action, array('manager' => $manager, 'request' => $request, 'exception' => $authException));
     }
     return new RedirectResponse($manager->getServer()->getLoginUrl());
 }
All Usage Examples Of Symfony\Bundle\FrameworkBundle\HttpKernel::forward