You are here

public function GeolocateUserSubscriber::geolocateUser in Smart IP 8.4

Same name and namespace in other branches
  1. 8.2 src/EventSubscriber/GeolocateUserSubscriber.php \Drupal\smart_ip\EventSubscriber\GeolocateUserSubscriber::GeolocateUser()
  2. 8.3 src/EventSubscriber/GeolocateUserSubscriber.php \Drupal\smart_ip\EventSubscriber\GeolocateUserSubscriber::geolocateUser()

Initiate user geolocation.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The response event, which contains the current request.

File

src/EventSubscriber/GeolocateUserSubscriber.php, line 28
Contains \Drupal\smart_ip\EventSubscriber\GeolocateUserSubscriber.

Class

GeolocateUserSubscriber
Allows Smart IP to act on HTTP request event.

Namespace

Drupal\smart_ip\EventSubscriber

Code

public function geolocateUser(GetResponseEvent $event) {

  // Check to see if the page is one of those allowed for geolocation.
  if (!SmartIp::checkAllowedPage()) {

    // This page is not on the list to acquire/update user's geolocation.
    return;
  }

  // Save a database hit.
  SmartIp::updateUserLocation();
}