You are here

Helper.php in Anti Spam by CleanTalk 8.3

File

src/lib/Cleantalk/ApbctDrupal/Helper.php
View source
<?php

/**
 * Helper class For Drupal 8
 */
namespace Drupal\cleantalk\lib\Cleantalk\ApbctDrupal;

class Helper extends \Drupal\cleantalk\lib\Cleantalk\Common\Helper {

  /*
   * Reload original Cleantalk\Common\Helper method
   */
  public static function ip_get($ips_input = array(
    'real',
    'remote_addr',
    'x_forwarded_for',
    'x_real_ip',
    'cloud_flare',
  ), $v4_only = true) {

    // If we need only REAL ip
    if (count($ips_input) == 1 && in_array('real', $ips_input) && \Drupal::request() !== null) {
      return \Drupal::request()
        ->getClientIp();
    }
    else {
      return parent::ip_get($ips_input, $v4_only) ? parent::ip_get($ips_input, $v4_only) : '::1';
    }
  }

}

Classes

Namesort descending Description
Helper