public function DeviceGeolocationController::check in Smart IP 8.4
Same name and namespace in other branches
- 8.3 modules/device_geolocation/src/Controller/DeviceGeolocationController.php \Drupal\device_geolocation\Controller\DeviceGeolocationController::check()
Check for Geolocation attempt.
1 string reference to 'DeviceGeolocationController::check'
- device_geolocation.routing.yml in modules/
device_geolocation/ device_geolocation.routing.yml - modules/device_geolocation/device_geolocation.routing.yml
File
- modules/
device_geolocation/ src/ Controller/ DeviceGeolocationController.php, line 70 - Contains \Drupal\device_geolocation\Controller\DeviceGeolocationController.
Class
- DeviceGeolocationController
- Ajax callback handler for Device Geolocation module.
Namespace
Drupal\device_geolocation\ControllerCode
public function check(Request $request) {
if (SmartIp::checkAllowedPage() && DeviceGeolocation::isNeedUpdate()) {
$json = [
'askGeolocate' => TRUE,
];
/** @var \Drupal\smart_ip\SmartIpLocation $location */
$location = \Drupal::service('smart_ip.smart_ip_location');
// Send current user's geolocation to javascript.
$json['device_geolocation'] = $location
->getData(FALSE);
$debugMode = SmartIp::isUserDebugMode();
//$debugMode = FALSE;
$json['device_geolocation']['debugMode'] = $debugMode;
$json['device_geolocation']['askGeolocate'] = TRUE;
}
else {
$json = [
'askGeolocate' => FALSE,
];
}
return new JsonResponse($json);
}