private function MobileDeviceDetection::check in Mobile Device Detection 8.2
Same name and namespace in other branches
- 8.3 src/Object/MobileDeviceDetection.php \Drupal\mobile_device_detection\Object\MobileDeviceDetection::check()
1 call to MobileDeviceDetection::check()
- MobileDeviceDetection::init in src/
Object/ MobileDeviceDetection.php
File
- src/
Object/ MobileDeviceDetection.php, line 168
Class
- MobileDeviceDetection
- MobileDeviceDetection object.
Namespace
Drupal\mobile_device_detection\ObjectCode
private function check($type) {
if ($this
->getUserAgentHeaders() === 'Amazon CloudFront') {
$headers = $this
->setCloudHeaders();
if (array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $headers) && $headers['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
return TRUE;
}
}
switch ($type) {
case 'mobile':
$options = array_merge($this
->getAttributes()
->get('phone_devices'));
$headers = array_intersect_key($this
->getAttributes()
->get('mobile_headers'), $this
->getMobileHeaders());
foreach ($headers as $key => $value) {
foreach ($value as $v) {
if (strpos($this
->getMobileHeaders()[$key], $v) !== FALSE) {
return TRUE;
}
}
}
goto device_detect;
break;
case 'tablet':
$options = array_merge($this
->getAttributes()
->get('tablet_devices'));
case 'deviceDetect':
device_detect:
foreach ($options as $value) {
if (!empty($value)) {
if ($this
->match($value)) {
return TRUE;
}
}
}
break;
}
return FALSE;
}