Skip to content

Commit

Permalink
add 'locales' config option
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-gribanov committed Jan 25, 2017
1 parent e85b6ef commit aa23be7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ gpslab_geoip:
# URL for download new GeoIP database.
# It's a default value. You can change it.
url: 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz'

# Get model data in this locale
# It's a default value. You can change it.
locales: [ '%locale%' ]
```

## Usage
Expand Down
6 changes: 6 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Configuration implements ConfigurationInterface
* gpslab_geoip:
* cache: '%kernel.cache_dir%/GeoLite2-City.mmdb'
* url: 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz'
* locales: [ '%locale%' ]
*
* @return TreeBuilder
*/
Expand All @@ -38,6 +39,11 @@ public function getConfigTreeBuilder()
->cannotBeEmpty()
->defaultValue('http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz')
->end()
->arrayNode('locales')
->treatNullLike([])
->prototype('scalar')->end()
->defaultValue(['%locale%'])
->end()
->end()
->end()
;
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/GpsLabGeoIP2Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function load(array $configs, ContainerBuilder $container)

$container->setParameter('geoip2.cache', $config['cache']);
$container->setParameter('geoip2.url', $config['url']);
$container->setParameter('geoip2.locales', $config['locales']);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
geoip2.reader:
class: GeoIp2\Database\Reader
arguments: [ '%geoip2.cache%' ]
arguments: [ '%geoip2.cache%', '%geoip2.locales%' ]

gpslab.command.geoip2.update:
class: GpsLab\Bundle\GeoIP2Bundle\Command\UpdateDatabaseCommand
Expand Down

0 comments on commit aa23be7

Please sign in to comment.