Completed
Push — 2.0 ( 5f7d48 )
by Nicolas
02:24
created

DashboardServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 4
c 6
b 0
f 0
lcom 0
cbo 3
dl 0
loc 56
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 2
A provides() 0 4 1
1
<?php namespace Modules\Dashboard\Providers;
2
3
use Illuminate\Support\ServiceProvider;
4
use Modules\Dashboard\Entities\Widget;
5
use Modules\Dashboard\Repositories\Cache\CacheWidgetDecorator;
6
use Modules\Dashboard\Repositories\Eloquent\EloquentWidgetRepository;
7
use Modules\Workshop\Manager\StylistThemeManager;
8
9
class DashboardServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Indicates if loading of the provider is deferred.
13
     *
14
     * @var bool
15
     */
16
    protected $defer = false;
17
18
    /**
19
     * Register the service provider.
20
     *
21
     * @return void
22
     */
23
    public function register()
24
    {
25
        $this->app->bind(
26
            'Modules\Dashboard\Repositories\WidgetRepository',
27
            function () {
28
                $repository = new EloquentWidgetRepository(new Widget());
29
30
                if (! config('app.cache')) {
31
                    return $repository;
32
                }
33
34
                return new CacheWidgetDecorator($repository);
35
            }
36
        );
37
    }
38
39
    public function boot(StylistThemeManager $theme)
40
    {
41
        $this->publishes([
42
            __DIR__ . '/../Resources/views' => base_path('resources/views/asgard/dashboard'),
43
        ], 'views');
44
45
        $this->app['view']->prependNamespace(
46
            'dashboard',
47
            base_path('resources/views/asgard/dashboard')
48
        );
49
        $this->app['view']->prependNamespace(
50
            'dashboard',
51
            $theme->find(config('asgard.core.core.admin-theme'))->getPath() . '/views/modules/dashboard'
52
        );
53
    }
54
55
    /**
56
     * Get the services provided by the provider.
57
     *
58
     * @return array
59
     */
60
    public function provides()
61
    {
62
        return array();
63
    }
64
}
65