本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::duplicate方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::duplicate方法的具体用法?PHP Request::duplicate怎么用?PHP Request::duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Request
的用法示例。
在下文中一共展示了Request::duplicate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveTokenAction
/**
* @return \Symfony\Component\HttpFoundation\Response $response
*/
public function saveTokenAction()
{
if (!$this->request->query->has('oauth_token') || !$this->request->query->has('oauth_verifier')) {
return $this->goToSettingsAction();
}
$path['_controller'] = 'weaving_the_web_user.controller.twitter:getAccessTokenAction';
$subRequest = $this->request->duplicate(['oauth_token' => $this->request->get('oauth_token'), 'oauth_verifier' => $this->request->get('oauth_verifier')], null, $path);
/**
* @var \Symfony\Component\HttpFoundation\Response $response
*/
$response = $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
$content = $response->getContent();
$tokenParameters = json_decode($content, true);
if (json_last_error() !== JSON_ERROR_NONE) {
return $this->goToSettingsAction();
}
$this->persistToken($tokenParameters);
$subRequest = $this->request->duplicate(null, null, ['_controller' => 'weaving_the_web_user.controller.settings:showAction']);
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
示例2: redirect
protected function redirect($params, $event)
{
$subRequest = $this->request->duplicate(array(), null, $params);
$response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
$event->setResponse($response);
$event->stopPropagation();
}
示例3: getAuditFields
/**
* @return string Json encoded
*/
protected function getAuditFields()
{
$path = ['_controller' => 'OroDataAuditBundle:Api/Rest/Audit:getFields'];
$subRequest = $this->request->duplicate(['_format' => 'json'], null, $path);
$response = $this->httpKernel->handle($subRequest, HttpKernelInterface::MASTER_REQUEST);
return $response->getContent();
}
示例4: testDuplicate
/**
* @covers Symfony\Component\HttpFoundation\Request::duplicate
*/
public function testDuplicate()
{
$request = new Request(array('foo' => 'bar'), array('foo' => 'bar'), array('foo' => 'bar'), array(), array(), array('HTTP_FOO' => 'bar'));
$dup = $request->duplicate();
$this->assertEquals($request->query->all(), $dup->query->all(), '->duplicate() duplicates a request an copy the current query parameters');
$this->assertEquals($request->request->all(), $dup->request->all(), '->duplicate() duplicates a request an copy the current request parameters');
$this->assertEquals($request->attributes->all(), $dup->attributes->all(), '->duplicate() duplicates a request an copy the current attributes');
$this->assertEquals($request->headers->all(), $dup->headers->all(), '->duplicate() duplicates a request an copy the current HTTP headers');
$dup = $request->duplicate(array('foo' => 'foobar'), array('foo' => 'foobar'), array('foo' => 'foobar'), array(), array(), array('HTTP_FOO' => 'foobar'));
$this->assertEquals(array('foo' => 'foobar'), $dup->query->all(), '->duplicate() overrides the query parameters if provided');
$this->assertEquals(array('foo' => 'foobar'), $dup->request->all(), '->duplicate() overrides the request parameters if provided');
$this->assertEquals(array('foo' => 'foobar'), $dup->attributes->all(), '->duplicate() overrides the attributes if provided');
$this->assertEquals(array('foo' => array('foobar')), $dup->headers->all(), '->duplicate() overrides the HTTP header if provided');
}
示例5: generateSwitchLink
/**
* @param Request $request
* @param $view
*
* @return string
*/
private function generateSwitchLink(Request $request, $view)
{
$requestSwitchView = $request->duplicate();
$requestSwitchView->query->set('device_view', $view);
$requestSwitchView->server->set('QUERY_STRING', Request::normalizeQueryString(http_build_query($requestSwitchView->query->all(), null, '&')));
return $requestSwitchView->getUri();
}
示例6: attemptAuthentication
/**
* {@inheritdoc}
*/
protected function attemptAuthentication(Request $request)
{
$openIdRequest = $request->duplicate();
if (false == empty($this->options['required_attributes'])) {
$openIdRequest->attributes->set('required_attributes', $this->options['required_attributes']);
}
if (false == empty($this->options['optional_attributes'])) {
$openIdRequest->attributes->set('optional_attributes', $this->options['optional_attributes']);
}
$result = $this->getRelyingParty()->manage($openIdRequest);
if ($result instanceof RedirectResponse) {
if ($targetUrl = $request->get($this->options['target_path_parameter'], null, true)) {
$request->getSession()->set('_security.' . $this->providerKey . '.target_path', $targetUrl);
}
return $result;
}
if ($result instanceof IdentityProviderResponse) {
$token = new OpenIdToken($this->providerKey, $result->getIdentity());
$token->setAttributes($result->getAttributes());
try {
return $this->authenticationManager->authenticate($token);
} catch (AuthenticationException $e) {
$e->setToken($token);
throw $e;
}
}
throw new \RuntimeException(sprintf('The relying party %s::manage() must either return a RedirectResponse or instance of IdentityProviderResponse.', get_class($this->getRelyingParty())));
}
示例7: start
/**
* @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) {
$subRequest = $request->duplicate(null, null, array('_controller' => $action, 'manager' => $manager, 'request' => $request, 'exception' => $authException));
return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
return new RedirectResponse($manager->getServer()->getLoginUrl());
}
示例8: getPreprocessorWriterResponse
public function getPreprocessorWriterResponse($preprocessorRouteName, array $attributes, Request $currentRequest)
{
// For localhost, the way is the same as for public to private forward.
$attributes['_controller'] = $this->router->getRouteCollection()->get($preprocessorRouteName)->getDefault('_controller');
$subRequest = $currentRequest->duplicate(null, null, $attributes);
$response = $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
/* @var $response \Symfony\Component\HttpFoundation\Response */
$response->setStatusCode($response->getStatusCode(), $response->headers->get('ps_status_text', null));
return $response;
}
示例9: previewErrorPageAction
public function previewErrorPageAction(Request $request, $code)
{
$exception = FlattenException::create(new \Exception('Something has intentionally gone wrong.'), $code);
/*
* This Request mimics the parameters set by
* \Symfony\Component\HttpKernel\EventListener\ExceptionListener::duplicateRequest, with
* the additional "showException" flag.
*/
$subRequest = $request->duplicate(null, null, array('_controller' => $this->controller, 'exception' => $exception, 'logger' => null, 'format' => $request->getRequestFormat(), 'showException' => false));
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
示例10: handle
/**
* Handles an access denied failure.
*
* @param Request $request
* @param AccessDeniedException $accessDeniedException
*
* @return Response may return null
*/
public function handle(Request $request, AccessDeniedException $accessDeniedException)
{
# First we check if user has an access granted to the frontend
if ($this->securityContext->isGranted('ROLE_FRONTEND_USER')) {
return new RedirectResponse($this->router->generate('baikal_frontend_homepage'));
}
# If not, we display an "Access denied" message
$attributes = array('_controller' => 'BaikalCoreBundle:Security:accessDenied', 'exception' => $accessDeniedException);
$subRequest = $request->duplicate(array(), null, $attributes);
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
示例11: indexAction
/**
* Sitemap preview index action.
*
* @param Request $request
*
* @return Response
*
* @throws NotFoundHttpException
*/
public function indexAction(Request $request)
{
$route = null;
if (null !== ($routePattern = $request->get('route', null))) {
$route = $this->routeManager->findByRoutePattern($routePattern);
}
if (null === $route) {
throw new NotFoundHttpException(sprintf('Not found route: %s', $routePattern));
}
$query = array('_route_params' => array('_route_object' => $route));
$subRequest = $request->duplicate($query, null, $route->getDefaults());
return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
示例12: handle
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$pathInfo = rawurldecode($request->getPathInfo());
foreach ($this->map as $path => $app) {
if (0 === strpos($pathInfo, $path)) {
$server = $request->server->all();
$server['SCRIPT_FILENAME'] = $server['SCRIPT_NAME'] = $server['PHP_SELF'] = $request->getBaseUrl() . $path;
$attributes = $request->attributes->all();
$attributes[static::ATTR_PREFIX] = $request->getBaseUrl() . $path;
$newRequest = $request->duplicate(null, null, $attributes, null, null, $server);
return $app->handle($newRequest, $type, $catch);
}
}
return $this->app->handle($request, $type, $catch);
}
示例13: handle
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$uri = rawurldecode($request->getUri());
#Broken into lines to be compatible with php5.3
$subDomain = explode('/', $uri);
$subDomain = $subDomain[2];
$subDomain = explode('.', $subDomain);
$subDomain = $subDomain[0];
foreach ($this->map as $pattern => $app) {
if (preg_match($pattern, $subDomain)) {
$newRequest = $request->duplicate();
return $app->handle($newRequest, $type, $catch);
}
}
return $this->app->handle($request, $type, $catch);
}
示例14: handle
protected function handle(Request $request)
{
$groupId = Auth::getGroupId();
$uploadIds = $request->get('uploads') ?: array();
$uploadIds[] = intval($request->get('upload'));
$addUploads = array();
foreach ($uploadIds as $uploadId) {
if (empty($uploadId)) {
continue;
}
try {
$addUploads[$uploadId] = $this->getUpload($uploadId, $groupId);
} catch (Exception $e) {
return $this->flushContent($e->getMessage());
}
}
$folderId = $request->get('folder');
if (!empty($folderId)) {
/* @var $folderDao FolderDao */
$folderDao = $this->getObject('dao.folder');
$folderUploads = $folderDao->getFolderUploads($folderId, $groupId);
foreach ($folderUploads as $uploadProgress) {
$addUploads[$uploadProgress->getId()] = $uploadProgress;
}
}
if (empty($addUploads)) {
return $this->flushContent(_('No upload selected'));
}
$upload = array_pop($addUploads);
try {
list($jobId, $jobQueueId) = $this->getJobAndJobqueue($groupId, $upload, $addUploads);
} catch (Exception $ex) {
return $this->flushContent($ex->getMessage());
}
$vars = array('jqPk' => $jobQueueId, 'downloadLink' => Traceback_uri() . "?mod=download&report=" . $jobId, 'reportType' => "ReadMe_OSS");
$text = sprintf(_("Generating ReadMe_OSS for '%s'"), $upload->getFilename());
$vars['content'] = "<h2>" . $text . "</h2>";
$content = $this->renderer->loadTemplate("report.html.twig")->render($vars);
$message = '<h3 id="jobResult"></h3>';
$request->duplicate(array('injectedMessage' => $message, 'injectedFoot' => $content, 'mod' => 'showjobs'))->overrideGlobals();
$showJobsPlugin = \plugin_find('showjobs');
$showJobsPlugin->OutputOpen();
return $showJobsPlugin->getResponse();
}
示例15: attemptAuthentication
/**
* Performs authentication.
* @param Request $request A Request instance
* @throws \Exception
* @throws \Symfony\Component\Security\Core\Exception\AuthenticationException
* @throws \RuntimeException
* @return TokenInterface|Response|null The authenticated token, null if full authentication is not possible, or a Response
*/
protected function attemptAuthentication(Request $request)
{
$myRequest = $request->duplicate();
$this->copyOptionsToRequestAttributes($myRequest);
if (!$this->getRelyingParty()->supports($myRequest)) {
return null;
}
$result = $this->getRelyingParty()->manage($myRequest);
if ($result instanceof Response) {
return $result;
}
if ($result instanceof SamlSpInfo) {
$token = new SamlSpToken($this->providerKey);
$token->setSamlSpInfo($result);
try {
return $this->authenticationManager->authenticate($token);
} catch (AuthenticationException $e) {
$e->setToken($token);
throw $e;
}
}
return null;
}