SidebarExtender::extendWith()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 2
eloc 11
nc 2
nop 1
1
<?php namespace Modules\Translation\Sidebar;
2
3
use Maatwebsite\Sidebar\Group;
4
use Maatwebsite\Sidebar\Item;
5
use Maatwebsite\Sidebar\Menu;
6
use Modules\Core\Contracts\Authentication;
7
8
class SidebarExtender implements \Maatwebsite\Sidebar\SidebarExtender
9
{
10
    /**
11
     * @var Authentication
12
     */
13
    protected $auth;
14
15
    /**
16
     * @param Authentication $auth
17
     *
18
     * @internal param Guard $guard
19
     */
20
    public function __construct(Authentication $auth)
21
    {
22
        $this->auth = $auth;
23
    }
24
25
    /**
26
     * @param Menu $menu
27
     *
28
     * @return Menu
29
     */
30
    public function extendWith(Menu $menu)
31
    {
32
        if (false === config('app.translations-gui')) {
33
            return $menu;
34
        }
35
        $menu->group(trans('core::sidebar.content'), function (Group $group) {
36
            $group->item(trans('translation::translations.title.translations'), function (Item $item) {
37
                $item->icon('fa fa-globe');
38
                $item->weight(10);
39
                $item->route('admin.translation.translation.index');
40
                $item->authorize(
41
                    $this->auth->hasAccess('translation.translations.index')
42
                );
43
            });
44
        });
45
46
        return $menu;
47
    }
48
}
49