Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $app->get('/', function(Request $request) {
});

$stack = (new \Stack\Builder())
->push('Ducks\Stack\GeoIp')
->push('Geocoder\Stack\GeoIp')
;

$app = $stack->resolve($app);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"stack/callable-http-kernel": "~1.0@dev"
},
"autoload": {
"psr-0": { "Ducks": "src" }
"psr-0": { "Geocoder": "src" }
}
}
28 changes: 0 additions & 28 deletions src/Ducks/Stack/GeoIp/ContainerConfig.php

This file was deleted.

15 changes: 13 additions & 2 deletions src/Ducks/Stack/GeoIp.php → src/Geocoder/Stack/GeoIp.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
<?php

namespace Ducks\Stack;
/**
* This file is part of the StackGeoIp package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/

use Ducks\Stack\GeoIp\ContainerConfig;
namespace Geocoder\Stack;

use Geocoder\Stack\GeoIp\ContainerConfig;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
* @author Andy Leon <[email protected]>
*/
class GeoIp implements HttpKernelInterface
{

Expand Down
42 changes: 42 additions & 0 deletions src/Geocoder/Stack/GeoIp/ContainerConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* This file is part of the StackGeoIp package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/

namespace Geocoder\Stack\GeoIp;

use Geocoder\Geocoder;
use Geocoder\HttpAdapter\CurlHttpAdapter;
use Geocoder\Provider\FreeGeoIpProvider;
use Pimple;

/**
* @author Andy Leon <[email protected]>
*/
class ContainerConfig
{
public function process(Pimple $container)
{
$container['geocoder'] = $container->share(function($container) {
$geocoder = new Geocoder();
$geocoder->registerProvider($container['provider']);

return $geocoder;
});

$container['provider'] = $container->share(function($container) {
return new FreeGeoIpProvider($container['adapter']);
});

$container['adapter'] = $container->share(function($container) {
return new CurlHttpAdapter();
});

$container['header'] = 'X-Country';
}
}
2 changes: 1 addition & 1 deletion tests/integration/GeoIpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function setUp()
});

$stack = new \Stack\Builder();
$stack->push('\Ducks\Stack\GeoIp', array('provider' => $provider));
$stack->push('Geocoder\Stack\GeoIp', array('provider' => $provider));

$this->app = $stack->resolve($app);
}
Expand Down