ThemeChanger   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 23
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 2
1
<?php
2
3
namespace Yajra\CMS\Themes;
4
5
use Closure;
6
7
class ThemeChanger
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param  \Illuminate\Http\Request $request
13
     * @param  \Closure $next
14
     * @return mixed
15
     */
16
    public function handle($request, Closure $next)
17
    {
18
        if ($theme = $request->query('cms-theme')) {
19
            $finder   = app('themes.view.finder');
20
            $basePath = config('themes.path.frontend', base_path('themes/frontend'));
21
            $finder->removeBasePath();
22
            $finder->setBasePath($basePath . DIRECTORY_SEPARATOR . $theme);
23
24
            config(['themes.frontend' => $theme]);
25
        }
26
27
        return $next($request);
28
    }
29
}
30