Completed
Push — 2.0 ( f3c215...8251a6 )
by Nicolas
03:40
created

SidebarServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 3
rs 10
c 2
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
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->onBackend() === true ) {
25
            $manager->register(AdminSidebar::class);
26
        }
27
    }
28
29
    private function onBackend()
30
    {
31
        $url = $this->request->url();
32
        if (str_contains($url, config('asgard.core.core.admin-prefix'))) {
33
            return true;
34
        }
35
        return false;
36
    }
37
}
38