-
-
Save Kindari/6636837 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
'provider' => 'Geocoder\Provider\FreeGeoIpProvider', | |
'adapter' => 'Geocoder\HttpAdapter\CurlHttpAdapter' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file is part of the GeocoderLaravel library. | |
* | |
* (c) Antoine Corcy <[email protected]> | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file that was distributed with this source code. | |
*/ | |
namespace Toin0u\Geocoder; | |
use Geocoder\Geocoder; | |
use Illuminate\Support\ServiceProvider; | |
/** | |
* Geocoder service provider | |
* | |
* @author Antoine Corcy <[email protected]> | |
*/ | |
class GeocoderServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Indicates if loading of the provider is deferred. | |
* | |
* @var bool | |
*/ | |
protected $defer = false; | |
/** | |
* Bootstrap the application events. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
$this->package('toin0u/geocoder-laravel'); | |
} | |
/** | |
* Register the service provider. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
$this->registerAdapter(); | |
$this->registerProvider(); | |
$this->registerGeocoder(); | |
} | |
public function registerAdapter() { | |
$this->app->singleton( 'geocoder.adapter', | |
$this->app['config']->get('geocoder-laravel::adapter', 'Geocoder\HttpAdapter\CurlHttpAdapter') | |
); | |
} | |
public function registerProvider() { | |
$this->app->singleton( 'geocoder.provider', | |
$this->app['config']->get('geocoder-laravel::provider', 'Geocoder\Provider\FreeGeoIpProvider') | |
); | |
} | |
public function registerGeocoder() { | |
$this->app['geocoder'] = $this->app->share(function($app) { | |
$geocoder = new Geocoder; | |
$geocoder->registerProvider($app['geocoder.provider']); | |
return $geocoder; | |
}); | |
} | |
/** | |
* Get the services provided by the provider. | |
* | |
* @return array | |
*/ | |
public function provides() | |
{ | |
return array('geocoder', 'geocoder.adapter', 'geocoder.provider'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment