From 543a4e6b7044a98c291b83eee9ca184b2478b862 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 5 Feb 2020 20:15:53 +0000 Subject: [PATCH] Move container bindings --- src/TranslationBindingsServiceProvider.php | 21 --------------------- src/TranslationServiceProvider.php | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/TranslationBindingsServiceProvider.php b/src/TranslationBindingsServiceProvider.php index 71d41de..8e73ab1 100644 --- a/src/TranslationBindingsServiceProvider.php +++ b/src/TranslationBindingsServiceProvider.php @@ -2,7 +2,6 @@ namespace JoeDixon\Translation; -use Illuminate\Filesystem\Filesystem; use Illuminate\Translation\TranslationServiceProvider as ServiceProvider; use Illuminate\Translation\Translator; use JoeDixon\Translation\Drivers\Translation; @@ -16,8 +15,6 @@ class TranslationBindingsServiceProvider extends ServiceProvider */ public function register() { - $this->registerContainerBindings(); - if ($this->app['config']['translation.driver'] === 'database') { $this->registerDatabaseTranslator(); } else { @@ -55,22 +52,4 @@ protected function registerDatabaseLoader() return new InterfaceDatabaseLoader($this->app->make(Translation::class)); }); } - - /** - * Register package bindings in the container. - * - * @return void - */ - private function registerContainerBindings() - { - $this->app->singleton(Scanner::class, function () { - $config = $this->app['config']['translation']; - - return new Scanner(new Filesystem, $config['scan_paths'], $config['translation_methods']); - }); - - $this->app->singleton(Translation::class, function ($app) { - return (new TranslationManager($app, $app['config']['translation'], $app->make(Scanner::class)))->resolve(); - }); - } } diff --git a/src/TranslationServiceProvider.php b/src/TranslationServiceProvider.php index c8198bf..c8f90b4 100644 --- a/src/TranslationServiceProvider.php +++ b/src/TranslationServiceProvider.php @@ -2,6 +2,7 @@ namespace JoeDixon\Translation; +use Illuminate\Filesystem\Filesystem; use Illuminate\Support\ServiceProvider; use JoeDixon\Translation\Console\Commands\AddLanguageCommand; use JoeDixon\Translation\Console\Commands\AddTranslationKeyCommand; @@ -9,6 +10,7 @@ use JoeDixon\Translation\Console\Commands\ListMissingTranslationKeys; use JoeDixon\Translation\Console\Commands\SynchroniseMissingTranslationKeys; use JoeDixon\Translation\Console\Commands\SynchroniseTranslationsCommand; +use JoeDixon\Translation\Drivers\Translation; class TranslationServiceProvider extends ServiceProvider { @@ -44,6 +46,8 @@ public function register() $this->mergeConfiguration(); $this->registerCommands(); + + $this->registerContainerBindings(); } /** @@ -156,4 +160,22 @@ private function registerHelpers() { require __DIR__.'/../resources/helpers.php'; } + + /** + * Register package bindings in the container. + * + * @return void + */ + private function registerContainerBindings() + { + $this->app->singleton(Scanner::class, function () { + $config = $this->app['config']['translation']; + + return new Scanner(new Filesystem, $config['scan_paths'], $config['translation_methods']); + }); + + $this->app->singleton(Translation::class, function ($app) { + return (new TranslationManager($app, $app['config']['translation'], $app->make(Scanner::class)))->resolve(); + }); + } }