Completed
Push — master ( 1c8f09...485292 )
by Mahmoud
06:58
created

LocalizationLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 18 2
1
<?php
2
3
namespace App\Ship\Engine\Loaders;
4
5
use App\Ship\Engine\Butlers\Facades\ShipButler;
6
use Illuminate\Translation\FileLoader;
7
use Illuminate\Translation\TranslationServiceProvider as LaravelTranslationServiceProvider;
8
9
/**
10
 * Class LocalizationServiceProvider.
11
 *
12
 * Extending the default Laravel Localization Loader to allow loading from multiple directories
13
 *
14
 * @author  Mahmoud Zalt <[email protected]>
15
 */
16
class LocalizationLoader extends LaravelTranslationServiceProvider
17
{
18
19
    /**
20
     * Register the service provider.
21
     *
22
     * @return void
23
     */
24
    public function register()
25
    {
26
        parent::register();
27
28
        $paths = [
29
            // first add the default laravel lang directory path
30
            $this->app['path.lang']
31
        ];
32
33
        // second append all the containers languages paths to the array
34
        foreach (ShipButler::getContainersNames() as $containerName) {
35
            $paths[] = app_path() . "/Containers/{$containerName}/Resources/Languages";
36
        }
37
38
        $this->app->singleton('translation.loader', function ($app) use ($paths){
39
            return new FileLoader($app['files'], $paths);
40
        });
41
    }
42
43
}
44