Skip to content

Commit

Permalink
Merge pull request #98 from joedixon/fix-bindings
Browse files Browse the repository at this point in the history
Move container bindings
  • Loading branch information
joedixon authored Feb 5, 2020
2 parents 65a01b8 + 543a4e6 commit d46cd7f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
21 changes: 0 additions & 21 deletions src/TranslationBindingsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,8 +15,6 @@ class TranslationBindingsServiceProvider extends ServiceProvider
*/
public function register()
{
$this->registerContainerBindings();

if ($this->app['config']['translation.driver'] === 'database') {
$this->registerDatabaseTranslator();
} else {
Expand Down Expand Up @@ -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();
});
}
}
22 changes: 22 additions & 0 deletions src/TranslationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace JoeDixon\Translation;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\ServiceProvider;
use JoeDixon\Translation\Console\Commands\AddLanguageCommand;
use JoeDixon\Translation\Console\Commands\AddTranslationKeyCommand;
use JoeDixon\Translation\Console\Commands\ListLanguagesCommand;
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
{
Expand Down Expand Up @@ -44,6 +46,8 @@ public function register()
$this->mergeConfiguration();

$this->registerCommands();

$this->registerContainerBindings();
}

/**
Expand Down Expand Up @@ -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();
});
}
}

0 comments on commit d46cd7f

Please sign in to comment.