Skip to content

Commit 2774c86

Browse files
committed
Merge pull request #90 from notrix/master
Use RouterInterface instead of Router class
2 parents 3a7d3db + 58d716c commit 2774c86

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

EventListener/RequestResponseListener.php

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@
1111

1212
namespace SunCat\MobileDetectBundle\EventListener;
1313

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;
1717
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;
2019
use Symfony\Component\HttpKernel\HttpKernelInterface;
2120
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;
2522

2623
/**
2724
* Request and response listener
@@ -65,23 +62,23 @@ class RequestResponseListener
6562
protected $needModifyResponse = false;
6663

6764
/**
68-
* @var mixed
65+
* @var \Closure
6966
*/
7067
protected $modifyResponseClosure;
7168

7269
/**
7370
* RequestResponseListener constructor.
7471
*
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
8077
*/
8178
public function __construct(
8279
MobileDetector $mobileDetector,
8380
DeviceView $deviceView,
84-
Router $router,
81+
RouterInterface $router,
8582
array $redirectConf,
8683
$fullPath = true
8784
)
@@ -221,9 +218,9 @@ protected function prepareResponseModification($view)
221218

222219
/**
223220
* Gets the RedirectResponse by switch param.
224-
*
221+
*
225222
* @param Request $request
226-
*
223+
*
227224
* @return \SunCat\MobileDetectBundle\Helper\RedirectResponseWithCookie
228225
*/
229226
protected function getRedirectResponseBySwitchParam(Request $request)
@@ -289,15 +286,15 @@ protected function getRedirectUrl(Request $request, $platform)
289286
$queryParams = $request->query->all();
290287
$queryParams[$this->deviceView->getSwitchParam()] = $platform;
291288

292-
return rtrim($this->redirectConf[$platform]['host'], '/') .
289+
return rtrim($this->redirectConf[$platform]['host'], '/') .
293290
$request->getPathInfo() . '?' .
294291
Request::normalizeQueryString(http_build_query($queryParams, null, '&'));
295292
} elseif (self::REDIRECT_WITHOUT_PATH === $routingOption) {
296293
// Make sure to hint at the device override, otherwise infinite loop
297294
// redirections may occur if different device views are hosted on
298295
// 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() . '=' .
301298
$platform;
302299
} else {
303300
return null;
@@ -339,7 +336,7 @@ protected function getRoutingOption($routeName, $optionName)
339336
* Gets the current host.
340337
*
341338
* @param Request $request
342-
*
339+
*
343340
* @return string
344341
*/
345342
protected function getCurrentHost(Request $request)

0 commit comments

Comments
 (0)