public function RestrictIpMapper::saveWhitelistedIpAddresses in Restrict IP 8
Same name and namespace in other branches
- 8.2 src/Mapper/RestrictIpMapper.php \Drupal\restrict_ip\Mapper\RestrictIpMapper::saveWhitelistedIpAddresses()
 - 3.x src/Mapper/RestrictIpMapper.php \Drupal\restrict_ip\Mapper\RestrictIpMapper::saveWhitelistedIpAddresses()
 
*
Overrides RestrictIpMapperInterface::saveWhitelistedIpAddresses
File
- src/
Mapper/ RestrictIpMapper.php, line 32  
Class
Namespace
Drupal\restrict_ip\MapperCode
public function saveWhitelistedIpAddresses(array $ip_addresses, $overwriteExisting = TRUE) {
  if ($overwriteExisting) {
    $this->connection
      ->query('DELETE FROM {restrict_ip_whitelisted_ip_addresses}');
  }
  $query = $this->connection
    ->insert('restrict_ip_whitelisted_ip_addresses')
    ->fields([
    'ip_address',
  ]);
  foreach ($ip_addresses as $ip_address) {
    $query
      ->values([
      'ip_address' => $ip_address,
    ]);
  }
  $query
    ->execute();
}