diff --git a/src/MollieServiceProvider.php b/src/MollieServiceProvider.php index a01235f..580ad32 100644 --- a/src/MollieServiceProvider.php +++ b/src/MollieServiceProvider.php @@ -17,24 +17,11 @@ class MollieServiceProvider extends ServiceProvider */ public function boot() { - $this->setupConfig(); - $this->extendSocialite(); - } - - /** - * Setup the config. - * - * @return void - */ - protected function setupConfig() - { - $source = realpath(__DIR__.'/../config/mollie.php'); - if ($this->app->runningInConsole()) { - $this->publishes([$source => config_path('mollie.php')]); + $this->publishes([__DIR__ . '/../config/mollie.php' => config_path('mollie.php')]); } - $this->mergeConfigFrom($source, 'mollie'); + $this->extendSocialite(); } /** @@ -62,18 +49,22 @@ protected function extendSocialite() */ public function register() { + $this->mergeConfigFrom(__DIR__ . '/../config/mollie.php', 'mollie'); + $this->app->singleton( MollieApiClient::class, function (Container $app) { $client = (new MollieApiClient(new MollieLaravelHttpClientAdapter)) - ->addVersionString('MollieLaravel/'.self::PACKAGE_VERSION); + ->addVersionString('MollieLaravel/' . self::PACKAGE_VERSION); - if (! empty($apiKey = $app['config']['mollie.key'])) { + if (!empty($apiKey = $app['config']['mollie.key'])) { $client->setApiKey($apiKey); } return $client; } ); + + $this->app->singleton(MollieManager::class); } }