Completed
Push — master ( 67c7d1...f02869 )
by Nicolas
02:52
created

SidebarServiceProvider::onBackend()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 8
rs 9.4285
c 3
b 0
f 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