Completed
Push — master ( da32d9...8024cd )
by ARCANEDEV
8s
created

LocalizationServiceProvider::publishConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\Localization;
2
3
use Arcanedev\Support\PackageServiceProvider;
4
5
/**
6
 * Class     LocalizationServiceProvider
7
 *
8
 * @package  Arcanedev\Localization
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class LocalizationServiceProvider extends PackageServiceProvider
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Vendor name.
19
     *
20
     * @var string
21
     */
22
    protected $vendor   = 'arcanedev';
23
24
    /**
25
     * Package name.
26
     *
27
     * @var string
28
     */
29
    protected $package  = 'localization';
30
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Getters & Setters
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * Get the base path of the package.
37
     *
38
     * @return string
39
     */
40 756
    public function getBasePath()
41
    {
42 756
        return dirname(__DIR__);
43
    }
44
45
    /* ------------------------------------------------------------------------------------------------
46
     |  Main Functions
47
     | ------------------------------------------------------------------------------------------------
48
     */
49
    /**
50
     * Register the service provider.
51
     */
52 756
    public function register()
53
    {
54 756
        $this->registerConfig();
55
56 756
        $this->app->register(Providers\RoutingServiceProvider::class);
57 756
        $this->app->register(Providers\UtilitiesServiceProvider::class);
58 756
        $this->registerLocalization();
59 756
        $this->registerAliases();
60 756
    }
61
62
    /**
63
     * Boot the package.
64
     */
65 756
    public function boot()
66
    {
67 756
        parent::boot();
68
69 756
        $this->publishConfig();
70 756
        $this->publishViews();
71 756
    }
72
73
    /**
74
     * Get the services provided by the provider.
75
     *
76
     * @return array
77
     */
78 12
    public function provides()
79
    {
80 12
        return ['arcanedev.localization'];
81
    }
82
83
    /* ------------------------------------------------------------------------------------------------
84
     |  Services Functions
85
     | ------------------------------------------------------------------------------------------------
86
     */
87
    /**
88
     * Register Localization.
89
     */
90
    private function registerLocalization()
91
    {
92 756
        $this->singleton('arcanedev.localization', function($app) {
93
            /**
94
             * @var  Contracts\RouteTranslatorInterface  $routeTranslator
95
             * @var  Contracts\LocalesManagerInterface   $localesManager
96
             */
97 756
            $routeTranslator = $app['arcanedev.localization.translator'];
98 756
            $localesManager  = $app['arcanedev.localization.locales-manager'];
99
100 756
            return new Localization($app, $routeTranslator, $localesManager);
101 756
        });
102
103 756
        $this->alias(
104 756
            $this->app['config']->get('localization.facade', 'Localization'),
105 189
            Facades\Localization::class
106 567
        );
107 756
    }
108
}
109