You are here

CheckIfEuCountryJsController.php in EU Cookie Compliance (GDPR Compliance) 2.0.x

Same filename and directory in other branches
  1. 8 src/Controller/CheckIfEuCountryJsController.php

File

src/Controller/CheckIfEuCountryJsController.php
View source
<?php

namespace Drupal\eu_cookie_compliance\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;

/**
 * Controller for JS call that checks if the visitor is in the EU.
 */
class CheckIfEuCountryJsController extends ControllerBase {

  /**
   * Check if visitor is in the EU.
   *
   * @return JsonResponse
   *   Whether the user is in EU.
   */
  public function content() {
    $data = eu_cookie_compliance_user_in_eu();

    // Allow other modules to alter the geo IP matching logic.
    \Drupal::moduleHandler()
      ->alter('eu_cookie_compliance_geoip_match', $data);
    return new JsonResponse($data, 200, [
      'Cache-Control' => 'private',
    ]);
  }

}

Classes

Namesort descending Description
CheckIfEuCountryJsController Controller for JS call that checks if the visitor is in the EU.