Completed
Push — master ( 379248...c97627 )
by ARCANEDEV
04:05
created

SidebarComposer::getSidebarItems()   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
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php namespace Arcanesoft\Foundation\ViewComposers;
2
3
use Arcanesoft\Core\Helpers\Sidebar\Contracts\Sidebar;
4
use Illuminate\Support\Arr;
5
use Illuminate\View\View;
6
7
/**
8
 * Class     SidebarComposer
9
 *
10
 * @package  Arcanesoft\Foundation\ViewComposers
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class SidebarComposer
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Properties
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * The Sidebar Helper instance.
21
     *
22
     * @var \Arcanesoft\Core\Helpers\Sidebar\Contracts\Sidebar
23
     */
24
    protected $sidebar;
25
26
    /* ------------------------------------------------------------------------------------------------
27
     |  Constructor
28
     | ------------------------------------------------------------------------------------------------
29
     */
30
    /**
31
     * SidebarComposer constructor.
32
     *
33
     * @param  \Arcanesoft\Core\Helpers\Sidebar\Contracts\Sidebar  $sidebar
34
     */
35
    public function __construct(Sidebar $sidebar)
36
    {
37
        $this->sidebar = $sidebar;
38
    }
39
40
    /* ------------------------------------------------------------------------------------------------
41
     |  Main Functions
42
     | ------------------------------------------------------------------------------------------------
43
     */
44
    /**
45
     * Bind data to the view.
46
     *
47
     * @param  \Illuminate\View\View  $view
48
     */
49
    public function compose(View $view)
50
    {
51
        foreach (config('arcanesoft.foundation.sidebar.items', []) as $sidebarKey) {
52
            if (config()->has($sidebarKey))
53
                $this->sidebar->add(config($sidebarKey));
54
        }
55
56
        $this->sidebar->setCurrent(
57
            Arr::get($view->getData(), 'current_page', '')
58
        );
59
    }
60
}
61