duplicate() public method

Clones a request and overrides some of its parameters.
public duplicate ( array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null ) : Request
$query array The GET parameters
$request array The POST parameters
$attributes array The request attributes (parameters parsed from the PATH_INFO, ...)
$cookies array The COOKIE parameters
$files array The FILES parameters
$server array The SERVER parameters
return Request The duplicated request
 /**
  * @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);
 }
 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();
 }
 /**
  * @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();
 }
 /**
  * @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();
 }
 /**
  * {@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())));
 }
 /**
  * @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());
 }
 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;
 }
Example #8
0
 /**
  * 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);
 }
 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);
 }
 /**
  * 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);
 }
Example #11
0
 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);
 }
 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);
 }
Example #13
0
 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();
 }
 /**
  * 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;
 }
Example #15
0
 /**
  * Returns the Request object that will be forwarded to the kernel for previewing the content.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param \eZ\Publish\Core\MVC\Symfony\SiteAccess $previewSiteAccess
  *
  * @return \Symfony\Component\HttpFoundation\Request
  */
 protected function getForwardRequest( Location $location, Content $content, SiteAccess $previewSiteAccess )
 {
     return $this->request->duplicate(
         null, null,
         array(
             '_controller' => 'ez_content:viewLocation',
             // specify a route for RouteReference generator
             '_route' => UrlAliasGenerator::INTERNAL_LOCATION_ROUTE,
             '_route_params' => array(
                 'locationId' => $location->id,
             ),
             'location' => $location,
             'viewType' => ViewManagerInterface::VIEW_TYPE_FULL,
             'layout' => true,
             'params' => array(
                 'content' => $content,
                 'location' => $location,
                 'isPreview' => true
             ),
             'siteaccess' => $previewSiteAccess,
             'semanticPathinfo' => $this->request->attributes->get( 'semanticPathinfo' ),
         )
     );
 }
Example #16
0
 /**
  * @Route("/password/update")
  * @Method("POST")
  *
  * @param Request $request
  *
  * Update the user's password.
  *
  * Parameters passed via POST:
  * ---------------------------
  * string oldpassword        The original password.
  * string newpassword        The new password to be stored for the user.
  * string newpasswordconfirm Verification of the new password to be stored for the user.
  *
  * Parameters passed via SESSION:
  * ------------------------------
  * Namespace: UsersConstant::SESSION_VAR_NAMESPACE
  * Variable:  User_updatePassword
  * Type:      array
  * Contents:  An array containing the information saved from the log-in attempt in order to re-enter it, including:
  *              'authentication_method', an array containing the selected authentication module name and method name,
  *              'authentication_info', an array containing the authentication information entered by the user,
  *              'user_obj', a user record containing the user information found during the log-in attempt,
  *              'password_errors', errors that have occurred during a previous pass through this function.
  *
  * @return RedirectResponse
  *
  * @throws AccessDeniedException Thrown if there is no POST information
  * @throws FatalErrorException Thrown if there are no arguments provided or
  *                                    if the user is logged in but the user is coming from the login process or
  * @throws \RuntimeException if there's a problem saving the new password
  */
 public function updatePasswordAction(Request $request)
 {
     $sessionVars = $request->getSession()->get('User_updatePassword', null, UsersConstant::SESSION_VAR_NAMESPACE);
     $request->getSession()->remove('User_updatePassword', UsersConstant::SESSION_VAR_NAMESPACE);
     $this->checkCsrfToken();
     if (isset($sessionVars) && !empty($sessionVars)) {
         $login = true;
         $userObj = $sessionVars['user_obj'];
     } else {
         $login = false;
         $userObj = UserUtil::getVars(UserUtil::getVar('uid'), true);
     }
     $uid = $userObj['uid'];
     if (!$login && !UserUtil::isLoggedIn()) {
         throw new AccessDeniedException();
     } elseif ($login && UserUtil::isLoggedIn()) {
         throw new FatalErrorException();
     }
     $passwordChanged = false;
     $currentPassword = $request->request->get('oldpassword', '');
     $newPassword = $request->request->get('newpassword', '');
     $newPasswordAgain = $request->request->get('newpasswordconfirm', '');
     $newPasswordReminder = $request->request->get('passreminder', '');
     $passwordErrors = array();
     if (empty($currentPassword) || !UserUtil::passwordsMatch($currentPassword, $userObj['pass'])) {
         $passwordErrors['oldpass'][] = $this->__('The current password you entered is not correct. Please correct your entry and try again.');
     } else {
         $passwordErrors = ModUtil::apiFunc($this->name, 'registration', 'getPasswordErrors', array('uname' => $userObj['uname'], 'pass' => $newPassword, 'passagain' => $newPasswordAgain, 'passreminder' => $newPasswordReminder));
         if ($login && $currentPassword == $newPassword) {
             $passwordErrors['reginfo_pass'][] = $this->__('Your new password cannot match your current password.');
         }
     }
     if (empty($passwordErrors)) {
         if (UserUtil::setPassword($newPassword, $uid)) {
             // no user.update event for password chagnes.
             $passwordChanged = true;
             // Clear the forced change of password flag, if it exists.
             UserUtil::delVar('_Users_mustChangePassword', $uid);
             if (!UserUtil::setVar('passreminder', $newPasswordReminder, $uid)) {
                 $request->getSession()->getFlashBag()->add('error', $this->__('Warning! Your new password was saved, however there was a problem saving your new password reminder.'));
             } else {
                 $request->getSession()->getFlashBag()->add('status', $this->__('Done! Saved your new password.'));
             }
             $userObj = UserUtil::getVars($uid, true);
             if ($login) {
                 $sessionVars['user_obj'] = $userObj;
                 if ($sessionVars['authentication_method']['modname'] == $this->name) {
                     // The password for Users module authentication was just changed.
                     // In order to successfully log in the user, we need to change it on the authentication_info.
                     $sessionVars['authentication_info']['pass'] = $newPassword;
                 }
             }
         } else {
             throw new \RuntimeException($this->__('Sorry! There was a problem saving your new password.'));
         }
     }
     if ($passwordChanged) {
         if ($login) {
             $sessionVars = $request->getSession()->get('User_login', array(), UsersConstant::SESSION_VAR_NAMESPACE);
             $post['authentication_method'] = $sessionVars['authentication_method'];
             $post['authentication_info'] = $sessionVars['authentication_info'];
             $post['rememberme'] = $sessionVars['rememberme'];
             $post['from_password_change'] = true;
             $subRequest = $request->duplicate(array(), $post, ['_controller' => 'ZikulaUsersModule:User:login']);
             $httpKernel = $this->get('http_kernel');
             $response = $httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
             return $response;
         } else {
             return new RedirectResponse($this->get('router')->generate('zikulausersmodule_user_index', array(), RouterInterface::ABSOLUTE_URL));
         }
     } else {
         $sessionVars['password_errors'] = $passwordErrors;
         SessionUtil::requireSession();
         $request->getSession()->set('User_changePassword', $sessionVars, UsersConstant::SESSION_VAR_NAMESPACE);
         return new RedirectResponse($this->get('router')->generate('zikulausersmodule_user_changepassword', array('login' => $login), RouterInterface::ABSOLUTE_URL));
     }
 }
Example #17
0
 /**
  * {@inheritdoc}
  */
 public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
 {
     return parent::duplicate($query, $request, $attributes, $cookies, array_filter((array) $files), $server);
 }
Example #18
0
 /**
  * @Route("/new")
  * @Method("GET")
  *
  * display new category form
  *
  * @param Request $request
  *
  * @return Response symfony response object
  */
 public function newcatAction(Request $request)
 {
     $path = array('_controller' => 'ZikulaCategoriesModule:Admin:edit', 'mode' => 'new');
     $subRequest = $request->duplicate($request->query->all(), $request->request->all(), $path);
     return $this->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
 }
 /**
  * Returns the Request object that will be forwarded to the kernel for previewing the content.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param \eZ\Publish\Core\MVC\Symfony\SiteAccess $previewSiteAccess
  * @param Request $request
  * @param string $language
  *
  * @return \Symfony\Component\HttpFoundation\Request
  */
 protected function getForwardRequest(Location $location, Content $content, SiteAccess $previewSiteAccess, Request $request, $language)
 {
     $forwardRequestParameters = array('_controller' => UrlAliasRouter::VIEW_ACTION, '_route' => UrlAliasGenerator::INTERNAL_CONTENT_VIEW_ROUTE, '_route_params' => array('contentId' => $content->id, 'locationId' => $location->id, 'language' => $language), 'location' => $location, 'viewType' => ViewManagerInterface::VIEW_TYPE_FULL, 'layout' => true, 'params' => array('content' => $content, 'location' => $location, 'isPreview' => true), 'siteaccess' => $previewSiteAccess, 'semanticPathinfo' => $request->attributes->get('semanticPathinfo'));
     if ($this->controllerChecker->usesCustomController($content, $location)) {
         $forwardRequestParameters = ['_controller' => 'ez_content:viewLocation', '_route' => self::INTERNAL_LOCATION_VIEW_ROUTE] + $forwardRequestParameters;
     }
     return $request->duplicate(null, null, $forwardRequestParameters);
 }
Example #20
0
 public static function forward(Request $request, HttpKernelInterface $httpKernel, $controller, array $path = [], array $query = [])
 {
     $path['_controller'] = $controller;
     $subRequest = $request->duplicate($query, null, $path);
     return $httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
 }
 /**
  * Language translations overview page for a configuration name.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   Page request object.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match.
  * @param string $plugin_id
  *   The plugin ID of the mapper.
  *
  * @return array
  *   Page render array.
  */
 public function itemPage(Request $request, RouteMatchInterface $route_match, $plugin_id)
 {
     /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
     $mapper = $this->configMapperManager->createInstance($plugin_id);
     $mapper->populateFromRouteMatch($route_match);
     $page = array();
     $page['#title'] = $this->t('Translations for %label', array('%label' => $mapper->getTitle()));
     $languages = $this->languageManager->getLanguages();
     if (count($languages) == 1) {
         drupal_set_message($this->t('In order to translate configuration, the website must have at least two <a href=":url">languages</a>.', array(':url' => $this->url('entity.configurable_language.collection'))), 'warning');
     }
     $original_langcode = $mapper->getLangcode();
     if (!isset($languages[$original_langcode])) {
         // If the language is not configured on the site, create a dummy language
         // object for this listing only to ensure the user gets useful info.
         $language_name = $this->languageManager->getLanguageName($original_langcode);
         $languages[$original_langcode] = new Language(array('id' => $original_langcode, 'name' => $language_name));
     }
     // We create a fake request object to pass into
     // ConfigMapperInterface::populateFromRouteMatch() for the different languages.
     // Creating a separate request for each language and route is neither easily
     // possible nor performant.
     $fake_request = $request->duplicate();
     $page['languages'] = array('#type' => 'table', '#header' => array($this->t('Language'), $this->t('Operations')));
     foreach ($languages as $language) {
         $langcode = $language->getId();
         // This is needed because
         // ConfigMapperInterface::getAddRouteParameters(), for example,
         // needs to return the correct language code for each table row.
         $fake_route_match = RouteMatch::createFromRequest($fake_request);
         $mapper->populateFromRouteMatch($fake_route_match);
         $mapper->setLangcode($langcode);
         // Prepare the language name and the operations depending on whether this
         // is the original language or not.
         if ($langcode == $original_langcode) {
             $language_name = '<strong>' . $this->t('@language (original)', array('@language' => $language->getName())) . '</strong>';
             // Check access for the path/route for editing, so we can decide to
             // include a link to edit or not.
             $edit_access = $this->accessManager->checkNamedRoute($mapper->getBaseRouteName(), $route_match->getRawParameters()->all(), $this->account);
             // Build list of operations.
             $operations = array();
             if ($edit_access) {
                 $operations['edit'] = array('title' => $this->t('Edit'), 'url' => Url::fromRoute($mapper->getBaseRouteName(), $mapper->getBaseRouteParameters(), ['query' => ['destination' => $mapper->getOverviewPath()]]));
             }
         } else {
             $language_name = $language->getName();
             $operations = array();
             // If no translation exists for this language, link to add one.
             if (!$mapper->hasTranslation($language)) {
                 $operations['add'] = array('title' => $this->t('Add'), 'url' => Url::fromRoute($mapper->getAddRouteName(), $mapper->getAddRouteParameters()));
             } else {
                 // Otherwise, link to edit the existing translation.
                 $operations['edit'] = array('title' => $this->t('Edit'), 'url' => Url::fromRoute($mapper->getEditRouteName(), $mapper->getEditRouteParameters()));
                 $operations['delete'] = array('title' => $this->t('Delete'), 'url' => Url::fromRoute($mapper->getDeleteRouteName(), $mapper->getDeleteRouteParameters()));
             }
         }
         $page['languages'][$langcode]['language'] = array('#markup' => $language_name);
         $page['languages'][$langcode]['operations'] = array('#type' => 'operations', '#links' => $operations);
     }
     return $page;
 }
 /**
  * Returns the Request object that will be forwarded to the kernel for previewing the content.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param \eZ\Publish\Core\MVC\Symfony\SiteAccess $previewSiteAccess
  *
  * @return \Symfony\Component\HttpFoundation\Request
  */
 protected function getForwardRequest(Location $location, Content $content, SiteAccess $previewSiteAccess)
 {
     return $this->request->duplicate(null, null, array('_controller' => 'ez_content:viewLocation', 'location' => $location, 'viewType' => ViewManagerInterface::VIEW_TYPE_FULL, 'layout' => true, 'params' => array('content' => $content, 'location' => $location, 'isPreview' => true), 'siteaccess' => $previewSiteAccess, 'semanticPathinfo' => $this->request->attributes->get('semanticPathinfo')));
 }
 /**
  * @param Request $request
  * @return Request
  */
 protected function duplicateRequest(Request $request)
 {
     $myRequest = $request->duplicate();
     foreach ($this->keysToCopy as $key) {
         $myRequest->attributes->set($key, $this->options[$key]);
     }
     return $myRequest;
 }
Example #24
0
 /**
  * Gets a fixed request.
  *
  * @param Request $request
  *
  * @return Request
  */
 public static function parseAndDuplicateRequest(Request $request)
 {
     $query = self::parseRequestParams($request->getQueryString());
     $body = self::parseRequestParams($request->getContent());
     return $request->duplicate($query, $body);
 }
 /**
  * Hash a request into a string that returns cache metadata
  *
  * @param Request $request
  * @return string
  */
 public function getCacheKey(Request $request)
 {
     $reducedRequest = $request->duplicate();
     $this->persistHeaders($reducedRequest->headers);
     return hash('sha256', (string) $reducedRequest);
 }
Example #26
0
 public function testDuplicateWithFormat()
 {
     $request = new Request(array(), array(), array('_format' => 'json'));
     $dup = $request->duplicate();
     $this->assertEquals('json', $dup->getRequestFormat());
     $this->assertEquals('json', $dup->attributes->get('_format'));
     $request = new Request();
     $request->setRequestFormat('xml');
     $dup = $request->duplicate();
     $this->assertEquals('xml', $dup->getRequestFormat());
 }
 /**
  * Forward to controller where form is displays.
  *
  * @param Request $request
  * @param string $routeName
  * @param array $parameters
  *
  * @return Response
  *
  * @throws RouteNotFoundException
  */
 protected function formRedirect(Request $request, $routeName, $parameters = [])
 {
     $router = $this->container->get('router');
     if ($router instanceof I18nRouter) {
         $collection = $router->getOriginalRouteCollection();
     } else {
         $collection = $router->getRouteCollection();
     }
     $route = $collection->get($routeName);
     if (is_null($route)) {
         throw new RouteNotFoundException('Not found route "' . $routeName . '"');
     }
     $attributes = array_merge($parameters, ['_controller' => $route->getDefault('_controller'), '_forwarded' => $request->attributes, '_route' => $routeName, '_route_params' => $parameters]);
     $subRequest = $request->duplicate($parameters, null, $attributes);
     return $this->container->get('http_kernel')->handle($subRequest);
 }
Example #28
0
 /**
  * Forwards the request to another action of this controller.
  *
  * @param Request $request
  * @param         $action  The action to forwards to.
  * @param array   $get     Array of GET parameters.
  * @param array   $post    Array of POST parameters.
  *
  * @return mixed
  */
 private function forward(Request $request, $action, $get = array(), $post = array())
 {
     $path = array('_controller' => 'ZikulaSearchModule:User:'******'http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
 }
 /**
  * {@inheritdoc}
  *
  * In contrast to the symfony base class, do not override POST requests to GET
  * requests.
  */
 protected function duplicateRequest(\Exception $exception, Request $request)
 {
     $attributes = array('_controller' => $this->controller, 'exception' => FlattenException::create($exception), 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : NULL, 'format' => $request->getRequestFormat());
     return $request->duplicate(NULL, NULL, $attributes);
 }
Example #30
-11
 /**
  * @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');
 }