Completed
Pull Request — master (#101)
by
unknown
02:55
created

SidebarServiceProvider::inAdministration()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 6
rs 9.4285
1
<?php namespace Modules\Core\Providers;
2
3
use Illuminate\Support\ServiceProvider;
4
use Maatwebsite\Sidebar\SidebarManager;
5
use Modules\Core\Sidebar\AdminSidebar;
6
use Illuminate\Http\Request;
7
8
class SidebarServiceProvider extends ServiceProvider
9
{
10
    protected $defer = true;
11
    private $request;
12
13
    /**
14
     * Register the service provider.
15
     * @return void
16
     */
17
    public function register()
18
    {
19
    }
20
21
    public function boot(SidebarManager $manager, Request $request)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
22
    {
23
        $this->request = $request;
24
        if ($this->inAdministration() === true ) {
25
            $manager->register(AdminSidebar::class);
26
        }
27
    }
28
29
    private function inAdministration()
30
    {
31
        $segment = config('laravellocalization.hideDefaultLocaleInURL', false) ? 1 : 2;
32
33
        return $this->app['request']->segment($segment) === $this->app['config']->get('asgard.core.core.admin-prefix');
34
    }
35
}
36