/**
  * Gets the RedirectResponse by switch param.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function getRedirectResponseBySwitchParam()
 {
     if ($this->mustRedirect($this->deviceView->getViewType())) {
         // Avoid unnecessary redirects: if we need to redirect to another view,
         // do it in one response while setting the cookie.
         $redirectUrl = $this->getRedirectUrl($this->deviceView->getViewType());
     } else {
         if (true === $this->isFullPath) {
             /* @var $request Request */
             $request = $this->container->get('request');
             $redirectUrl = $request->getUriForPath($request->getPathInfo());
             $queryParams = $request->query->all();
             if (array_key_exists('device_view', $queryParams)) {
                 unset($queryParams['device_view']);
             }
             if (sizeof($queryParams) > 0) {
                 $redirectUrl .= '?' . Request::normalizeQueryString(http_build_query($queryParams));
             }
         } else {
             $redirectUrl = $this->getCurrentHost();
         }
     }
     return $this->deviceView->getRedirectResponseBySwitchParam($redirectUrl);
 }
 /**
  * Collects data for the given Request and Response.
  *
  * @param Request    $request   A Request instance
  * @param Response   $response  A Response instance
  * @param \Exception $exception An Exception instance
  *
  * @api
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $this->data['currentView'] = $this->deviceView->getViewType();
     $this->data['views'] = array(array('label' => 'Full', 'link' => $this->generateSwitchLink($request, DeviceView::VIEW_FULL), 'isCurrent' => $this->deviceView->isFullView()), array('label' => 'Tablet', 'link' => $this->generateSwitchLink($request, DeviceView::VIEW_TABLET), 'isCurrent' => $this->deviceView->isTabletView()), array('label' => 'Mobile', 'link' => $this->generateSwitchLink($request, DeviceView::VIEW_MOBILE), 'isCurrent' => $this->deviceView->isMobileView()));
 }