You are here

public function RestrictIpMapper::saveWhitelistedPaths in Restrict IP 8

Same name and namespace in other branches
  1. 8.2 src/Mapper/RestrictIpMapper.php \Drupal\restrict_ip\Mapper\RestrictIpMapper::saveWhitelistedPaths()
  2. 3.x src/Mapper/RestrictIpMapper.php \Drupal\restrict_ip\Mapper\RestrictIpMapper::saveWhitelistedPaths()

*

Overrides RestrictIpMapperInterface::saveWhitelistedPaths

File

src/Mapper/RestrictIpMapper.php, line 59

Class

RestrictIpMapper

Namespace

Drupal\restrict_ip\Mapper

Code

public function saveWhitelistedPaths(array $whitelistedPaths, $overwriteExisting = TRUE) {
  if ($overwriteExisting) {
    $this->connection
      ->query('DELETE FROM {restrict_ip_paths} WHERE type = :white', [
      ':white' => 'white',
    ]);
  }
  $query = $this->connection
    ->insert('restrict_ip_paths')
    ->fields([
    'type',
    'path',
  ]);
  foreach ($whitelistedPaths as $whitelisted_path) {
    $query
      ->values([
      'type' => 'white',
      'path' => $whitelisted_path,
    ]);
  }
  $query
    ->execute();
}