public function __construct(RequestStack $stack, CacheProvider $cache, $deviceDetectorOptions)
{
$this->cacheManager = $cache;
$this->requestStack = $stack;
$this->setOptions($deviceDetectorOptions);
if (null !== $this->requestStack && $this->requestStack->getCurrentRequest()) {
$userAgent = $this->requestStack->getCurrentRequest()->headers->get('User-Agent');
} else {
$userAgent = '';
}
$this->deviceDetector = new \DeviceDetector\DeviceDetector($userAgent);
$this->deviceDetector->setCache($this->getCacheManager());
if (!empty($this->deviceDetectorOptions['discard_bot_information'])) {
$this->deviceDetector->discardBotInformation();
}
if (!empty($this->deviceDetectorOptions['skip_bot_detection'])) {
$this->deviceDetector->skipBotDetection();
}
$this->deviceDetector->parse();
}