Completed
Pull Request — master (#622)
by Micheal
13:27
created

LaravelModulesServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nwidart\Modules;
4
5
use Nwidart\Modules\Support\Stub;
6
7
class LaravelModulesServiceProvider extends ModulesServiceProvider
8
{
9
    /**
10
     * Booting the package.
11
     */
12 183
    public function boot()
13
    {
14 183
        $this->registerNamespaces();
15 183
        $this->registerModules();
16 183
    }
17
18
    /**
19
     * Register the service provider.
20
     */
21 183
    public function register()
22
    {
23 183
        $this->registerServices();
24 183
        $this->setupStubPath();
25 183
        $this->registerProviders();
26 183
    }
27
28
    /**
29
     * Setup stub path.
30
     */
31 183
    public function setupStubPath()
32
    {
33 183
        Stub::setBasePath(__DIR__ . '/Commands/stubs');
34
35
        $this->app->booted(function ($app) {
36 183
            if ($app['modules']->config('stubs.enabled') === true) {
37
                Stub::setBasePath($app['modules']->config('stubs.path'));
38
            }
39 183
        });
40 183
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 183 View Code Duplication
    protected function registerServices()
46
    {
47
        $this->app->singleton(FileRepository::class, function ($app) {
48 183
            $path = $app['config']->get('modules.paths.modules');
49
50 183
            return new Laravel\LaravelFileRepository($app, $path);
51 183
        });
52 183
        $this->app->alias(FileRepository::class, 'modules');
53 183
    }
54
}
55