Skip to content

Commit 1931657

Browse files
committed
Allow configuring local IP when using FakeIpPlugin
1 parent 054afbc commit 1931657

File tree

6 files changed

+15
-1
lines changed

6 files changed

+15
-1
lines changed

DependencyInjection/BazingaGeocoderExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function load(array $configs, ContainerBuilder $container)
5555

5656
if ($config['fake_ip']['enabled']) {
5757
$definition = $container->getDefinition(FakeIpPlugin::class);
58+
$definition->replaceArgument(0, $config['fake_ip']['local_ip']);
5859
$definition->replaceArgument(1, $config['fake_ip']['ip']);
5960
$definition->replaceArgument(2, $config['fake_ip']['use_faker']);
6061

DependencyInjection/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public function getConfigTreeBuilder()
8686
->end()
8787
->canBeEnabled()
8888
->children()
89+
->scalarNode('local_ip')
90+
->defaultValue('127.0.0.1')
91+
->end()
8992
->scalarNode('ip')->defaultNull()->end()
9093
->booleanNode('use_faker')->defaultFalse()->end()
9194
->end()

Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ services:
2222

2323
Bazinga\GeocoderBundle\Plugin\FakeIpPlugin:
2424
class: Bazinga\GeocoderBundle\Plugin\FakeIpPlugin
25-
arguments: ['127.0.0.1', ~, false]
25+
arguments: [~, ~, false]
2626

2727
Bazinga\GeocoderBundle\Command\GeocodeCommand:
2828
arguments: ['@Geocoder\ProviderAggregator']

Resources/doc/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ bazinga_geocoder:
206206
```
207207

208208
If set, the parameter will replace all instances of "127.0.0.1" in your queries and replace them with the given one.
209+
If you'd like to replace other ip instead of "127.0.0.1" (e.g. when using localhost inside a VM) you can set the optional `local_ip` parameter:
210+
211+
```yaml
212+
bazinga_geocoder:
213+
fake_ip:
214+
local_ip: 192.168.99.1 # default 127.0.0.1
215+
ip: 123.123.123.123
216+
```
209217

210218
You can also let [Faker](https://github.com/fzaninotto/Faker) generate fake ip for you.
211219

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function testGetConfigTreeBuilder()
3434

3535
$this->assertTrue($config['profiling']['enabled']);
3636
$this->assertTrue($config['fake_ip']['enabled']);
37+
$this->assertSame('192.168.99.1', $config['fake_ip']['local_ip']);
3738
$this->assertSame('33.33.33.11', $config['fake_ip']['ip']);
3839
}
3940

Tests/DependencyInjection/Fixtures/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bazinga_geocoder:
22
fake_ip:
3+
local_ip: 192.168.99.1
34
ip: 33.33.33.11
45
providers:
56
bing_maps:

0 commit comments

Comments
 (0)