You are here

function IpPosts::save in IP address manager 8.2

Save the IpTrack

Return value

type

File

src/IpPosts.php, line 35
Contains Drupal\ip\IpPosts

Class

IpPosts

Namespace

Drupal\ip

Code

function save() {
  $ip = $this->request
    ->getClientIp();
  $iplong = ip2long($ip);
  if (!empty($iplong) && is_numeric($this->entity
    ->id())) {
    return $this->connection
      ->insert('ip_posts')
      ->fields(array(
      'type' => $this->entity
        ->getEntityTypeId(),
      'id' => $this->entity
        ->id(),
      'ip' => $iplong,
    ))
      ->execute();
  }
}