Skip to content

Commit

Permalink
Add work-around for Lumen
Browse files Browse the repository at this point in the history
Fixes #124
  • Loading branch information
mikebronner committed Mar 25, 2018
1 parent 7881aa7 commit 9b899cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [4.0.8] - 25 Mar 2018
### Added
- work-around for missing `config_path()` function in Lumen.

## [4.0.7] - 25 Mar 2018
### Added
- optional dedicated cache store.
Expand Down
32 changes: 25 additions & 7 deletions src/Providers/GeocoderService.php
Expand Up @@ -21,22 +21,40 @@ class GeocoderService extends ServiceProvider

public function boot()
{
$configPath = __DIR__ . '/../../config/geocoder.php';
$this->publishes([$configPath => config_path('geocoder.php')], 'config');
$this->mergeConfigFrom($configPath, 'geocoder');
$this->app->singleton('geocoder', function () {
$configPath = __DIR__ . "/../../config/geocoder.php";
$this->publishes(
[$configPath => $this->configPath("geocoder.php")],
"config"
);
$this->mergeConfigFrom($configPath, "geocoder");
$this->app->singleton("geocoder", function () {
return (new ProviderAndDumperAggregator)
->registerProvidersFromConfig(collect(config('geocoder.providers')));
->registerProvidersFromConfig(collect(config("geocoder.providers")));
});
}

public function register()
{
$this->app->alias('Geocoder', Geocoder::class);
$this->app->alias("Geocoder", Geocoder::class);
}

public function provides() : array
{
return ['geocoder'];
return ["geocoder"];
}

protected function configPath(string $path = "") : string
{
if (function_exists("config_path")) {
return config_path($path);
}

$pathParts = [
app()->basePath(),
"config",
trim($path, "/"),
];

return implode("/", $pathParts);
}
}

0 comments on commit 9b899cf

Please sign in to comment.