public function createRequest(Request $request, $path)
{
if ($path && '/' !== $path[0] && 0 !== strpos($path, 'http')) {
$this->resetLocale($request);
$path = $this->generateUrl($path, true);
}
$newRequest = Request::create($path, 'get', array(), $request->cookies->all(), array(), $request->server->all());
if ($session = $request->getSession()) {
$newRequest->setSession($session);
}
if ($request->attributes->has(SecurityContextInterface::AUTHENTICATION_ERROR)) {
$newRequest->attributes->set(SecurityContextInterface::AUTHENTICATION_ERROR, $request->attributes->get(SecurityContextInterface::AUTHENTICATION_ERROR));
}
if ($request->attributes->has(SecurityContextInterface::ACCESS_DENIED_ERROR)) {
$newRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR, $request->attributes->get(SecurityContextInterface::ACCESS_DENIED_ERROR));
}
if ($request->attributes->has(SecurityContextInterface::LAST_USERNAME)) {
$newRequest->attributes->set(SecurityContextInterface::LAST_USERNAME, $request->attributes->get(SecurityContextInterface::LAST_USERNAME));
}
return $newRequest;
}