Skip to content

Commit

Permalink
Merge pull request #32 from ARCANEDEV/update-deferred_providers
Browse files Browse the repository at this point in the history
Defer the providers properly
  • Loading branch information
arcanedev-maroc authored Oct 3, 2019
2 parents 66994d5 + 198a67f commit 7ea6c92
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"extra": {
"laravel": {
"providers": [
"Arcanedev\\LaravelLang\\LaravelLangServiceProvider"
"Arcanedev\\LaravelLang\\LaravelLangServiceProvider",
"Arcanedev\\LaravelLang\\Providers\\DeferredServicesProvider",
"Arcanedev\\LaravelLang\\Providers\\TranslationServiceProvider"
]
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/LaravelLangServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public function register(): void

$this->registerConfig();

$this->app->registerDeferredProvider(Providers\DeferredServiceProvider::class);
$this->registerProvider(Providers\TranslationServiceProvider::class);

$this->registerCommands([
Commands\CheckCommand::class,
Commands\PublishCommand::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @package Arcanedev\LaravelLang\Providers
* @author ARCANEDEV <[email protected]>
*/
class DeferredServiceProvider extends ServiceProvider implements DeferrableProvider
class DeferredServicesProvider extends ServiceProvider implements DeferrableProvider
{
/* -----------------------------------------------------------------
| Main Methods
Expand Down
6 changes: 2 additions & 4 deletions src/Providers/TranslationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ class TranslationServiceProvider extends ServiceProvider
protected function registerLoader()
{
$this->app->singleton('translation.loader', function(Application $app) {
$config = $app['config'];

return new FileLoader(
$app['files'],
$app->langPath(),
$config->get('laravel-lang.vendor', ''),
$config->get('laravel-lang.locales', [])
$app['config']->get('laravel-lang.vendor', ''),
$app['config']->get('laravel-lang.locales', [])
);
});
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Providers/DeferredServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Arcanedev\LaravelLang\Tests\Providers;

use Arcanedev\LaravelLang\Providers\DeferredServiceProvider;
use Arcanedev\LaravelLang\Providers\DeferredServicesProvider;
use Arcanedev\LaravelLang\Tests\TestCase;

/**
Expand All @@ -16,7 +16,7 @@ class DeferredServiceProviderTest extends TestCase
| -----------------------------------------------------------------
*/

/** @var \Arcanedev\LaravelLang\Providers\DeferredServiceProvider */
/** @var \Arcanedev\LaravelLang\Providers\DeferredServicesProvider */
protected $provider;

/* -----------------------------------------------------------------
Expand All @@ -28,7 +28,7 @@ protected function setUp(): void
{
parent::setUp();

$this->provider = $this->app->getProvider(DeferredServiceProvider::class);
$this->provider = $this->app->getProvider(DeferredServicesProvider::class);
}

/* -----------------------------------------------------------------
Expand All @@ -43,7 +43,7 @@ public function it_can_be_instantiated()
\Illuminate\Support\ServiceProvider::class,
\Illuminate\Contracts\Support\DeferrableProvider::class,
\Arcanedev\Support\Providers\ServiceProvider::class,
\Arcanedev\LaravelLang\Providers\DeferredServiceProvider::class,
\Arcanedev\LaravelLang\Providers\DeferredServicesProvider::class,
];

foreach ($expectations as $expected) {
Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ protected function getPackageProviders($app)
{
return [
\Arcanedev\LaravelLang\LaravelLangServiceProvider::class,
\Arcanedev\LaravelLang\Providers\DeferredServicesProvider::class,
\Arcanedev\LaravelLang\Providers\TranslationServiceProvider::class,
];
}

Expand Down

0 comments on commit 7ea6c92

Please sign in to comment.