Load translations of plugins even disabled

This commit is contained in:
Pig Fang 2019-08-25 14:51:56 +08:00
parent 0c6fe77492
commit c976a5c5f8
2 changed files with 27 additions and 2 deletions

View File

@ -136,6 +136,10 @@ class PluginManager
return;
}
$this->all()->each(function ($plugin) {
$this->loadViewsAndTranslations($plugin);
});
$enabled = $this->getEnabledPlugins();
$enabled->each(function ($plugin) {
$this->registerPlugin($plugin);
@ -155,7 +159,6 @@ class PluginManager
{
$this->registerAutoload($plugin);
$this->loadVendor($plugin);
$this->loadViewsAndTranslations($plugin);
}
/**

View File

@ -212,7 +212,7 @@ class PluginManagerTest extends TestCase
$mock->shouldReceive('directories')
->with(base_path('plugins'))
->once()
->andReturn(collect(['/mayaka']));
->andReturn(collect(['/mayaka', '/chitanda']));
$mock->shouldReceive('exists')
->with('/mayaka'.DIRECTORY_SEPARATOR.'package.json')
@ -236,16 +236,38 @@ class PluginManagerTest extends TestCase
->with('/mayaka/bootstrap.php')
->once()
->andReturn(false);
$mock->shouldReceive('exists')
->with('/chitanda'.DIRECTORY_SEPARATOR.'package.json')
->once()
->andReturn(true);
$mock->shouldReceive('get')
->with('/chitanda'.DIRECTORY_SEPARATOR.'package.json')
->once()
->andReturn(json_encode([
'name' => 'chitanda',
'version' => '0.0.0',
'namespace' => 'Chitanda',
]));
});
$this->mock('view', function ($mock) {
$mock->shouldReceive('addNamespace')
->withArgs(['Mayaka', '/mayaka/views'])
->once();
$mock->shouldReceive('addNamespace')
->withArgs(['Chitanda', '/chitanda/views'])
->once();
});
$this->instance('translation.loader', \Mockery::mock(\App\Services\TranslationLoader::class, function ($mock) {
$mock->shouldReceive('addNamespace')
->withArgs(['Mayaka', '/mayaka/lang'])
->once();
$mock->shouldReceive('addNamespace')
->withArgs(['Chitanda', '/chitanda/lang'])
->once();
}));
app()->forgetInstance(PluginManager::class);