|
11 | 11 |
|
12 | 12 | namespace SunCat\MobileDetectBundle\EventListener; |
13 | 13 |
|
14 | | -use Symfony\Bundle\FrameworkBundle\Routing\Router; |
15 | | -use Symfony\Component\HttpFoundation\RequestStack; |
16 | | -use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
| 14 | +use SunCat\MobileDetectBundle\DeviceDetector\MobileDetector; |
| 15 | +use SunCat\MobileDetectBundle\Helper\DeviceView; |
| 16 | +use Symfony\Component\HttpFoundation\Request; |
17 | 17 | use Symfony\Component\HttpKernel\Event\FilterResponseEvent; |
18 | | -use Symfony\Component\DependencyInjection\Container; |
19 | | -use Symfony\Component\HttpKernel\Event\KernelEvent; |
| 18 | +use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
20 | 19 | use Symfony\Component\HttpKernel\HttpKernelInterface; |
21 | 20 | use Symfony\Component\Routing\Route; |
22 | | -use Symfony\Component\HttpFoundation\Request; |
23 | | -use SunCat\MobileDetectBundle\DeviceDetector\MobileDetector; |
24 | | -use SunCat\MobileDetectBundle\Helper\DeviceView; |
| 21 | +use Symfony\Component\Routing\RouterInterface; |
25 | 22 |
|
26 | 23 | /** |
27 | 24 | * Request and response listener |
@@ -65,23 +62,23 @@ class RequestResponseListener |
65 | 62 | protected $needModifyResponse = false; |
66 | 63 |
|
67 | 64 | /** |
68 | | - * @var mixed |
| 65 | + * @var \Closure |
69 | 66 | */ |
70 | 67 | protected $modifyResponseClosure; |
71 | 68 |
|
72 | 69 | /** |
73 | 70 | * RequestResponseListener constructor. |
74 | 71 | * |
75 | | - * @param MobileDetector $mobileDetector |
76 | | - * @param DeviceView $deviceView |
77 | | - * @param Router $router |
78 | | - * @param array $redirectConf |
79 | | - * @param bool $fullPath |
| 72 | + * @param MobileDetector $mobileDetector |
| 73 | + * @param DeviceView $deviceView |
| 74 | + * @param RouterInterface $router |
| 75 | + * @param array $redirectConf |
| 76 | + * @param bool $fullPath |
80 | 77 | */ |
81 | 78 | public function __construct( |
82 | 79 | MobileDetector $mobileDetector, |
83 | 80 | DeviceView $deviceView, |
84 | | - Router $router, |
| 81 | + RouterInterface $router, |
85 | 82 | array $redirectConf, |
86 | 83 | $fullPath = true |
87 | 84 | ) |
@@ -221,9 +218,9 @@ protected function prepareResponseModification($view) |
221 | 218 |
|
222 | 219 | /** |
223 | 220 | * Gets the RedirectResponse by switch param. |
224 | | - * |
| 221 | + * |
225 | 222 | * @param Request $request |
226 | | - * |
| 223 | + * |
227 | 224 | * @return \SunCat\MobileDetectBundle\Helper\RedirectResponseWithCookie |
228 | 225 | */ |
229 | 226 | protected function getRedirectResponseBySwitchParam(Request $request) |
@@ -289,15 +286,15 @@ protected function getRedirectUrl(Request $request, $platform) |
289 | 286 | $queryParams = $request->query->all(); |
290 | 287 | $queryParams[$this->deviceView->getSwitchParam()] = $platform; |
291 | 288 |
|
292 | | - return rtrim($this->redirectConf[$platform]['host'], '/') . |
| 289 | + return rtrim($this->redirectConf[$platform]['host'], '/') . |
293 | 290 | $request->getPathInfo() . '?' . |
294 | 291 | Request::normalizeQueryString(http_build_query($queryParams, null, '&')); |
295 | 292 | } elseif (self::REDIRECT_WITHOUT_PATH === $routingOption) { |
296 | 293 | // Make sure to hint at the device override, otherwise infinite loop |
297 | 294 | // redirections may occur if different device views are hosted on |
298 | 295 | // different domains (since the cookie can't be shared across domains) |
299 | | - return $this->redirectConf[$platform]['host'] . '?' . |
300 | | - $this->deviceView->getSwitchParam() . '=' . |
| 296 | + return $this->redirectConf[$platform]['host'] . '?' . |
| 297 | + $this->deviceView->getSwitchParam() . '=' . |
301 | 298 | $platform; |
302 | 299 | } else { |
303 | 300 | return null; |
@@ -339,7 +336,7 @@ protected function getRoutingOption($routeName, $optionName) |
339 | 336 | * Gets the current host. |
340 | 337 | * |
341 | 338 | * @param Request $request |
342 | | - * |
| 339 | + * |
343 | 340 | * @return string |
344 | 341 | */ |
345 | 342 | protected function getCurrentHost(Request $request) |
|
0 commit comments