Completed
Push — master ( d1e582...ed2250 )
by ARCANEDEV
03:49
created

ViewComposerServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php namespace Arcanedev\Support\Providers;
2
3
use Arcanedev\Support\ServiceProvider;
4
use Illuminate\Contracts\View\Factory as ViewFactory;
5
6
/**
7
 * Class     ViewComposerServiceProvider
8
 *
9
 * @package  Arcanedev\Support\Providers
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class ViewComposerServiceProvider extends ServiceProvider
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Register the composer classes.
20
     *
21
     * @var array
22
     */
23
    protected $composerClasses = [
24
        // 'view-name' => 'class'
25
    ];
26
27
    /* ------------------------------------------------------------------------------------------------
28
     |  Main Functions
29
     | ------------------------------------------------------------------------------------------------
30
     */
31
    /**
32
     * Boot the view composer service provider.
33
     */
34
    public function boot()
35
    {
36
        $this->registerComposerClasses();
37
    }
38
39
    /**
40
     * Register the view composer classes.
41
     */
42
    protected function registerComposerClasses()
43
    {
44
        foreach ($this->composerClasses as $view => $class) {
45
            $this->composer($view, $class);
46
        }
47
    }
48
49
    /* ------------------------------------------------------------------------------------------------
50
     |  Other Functions
51
     | ------------------------------------------------------------------------------------------------
52
     */
53
    /**
54
     * Get the view factory instance.
55
     *
56
     * @return \Illuminate\Contracts\View\Factory
57
     */
58
    protected function view()
59
    {
60
        return $this->app->make(ViewFactory::class);
61
    }
62
63
    /**
64
     * Register a view composer event.
65
     *
66
     * @param  array|string     $views
67
     * @param  \Closure|string  $callback
68
     *
69
     * @return array
70
     */
71
    public function composer($views, $callback)
72
    {
73
        return $this->view()->composer($views, $callback);
74
    }
75
}
76