RuntimeTheme   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

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 RuntimeTheme
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param  \Illuminate\Http\Request $request
13
     * @param  \Closure $next
14
     * @param  string|null $theme
15
     * @return mixed
16
     */
17
    public function handle($request, Closure $next, $theme = null)
18
    {
19
        $theme = $theme ?: config('themes.frontend', 'default');
20
21
        $finder   = app('themes.view.finder');
22
        $basePath = config('themes.path.frontend', base_path('themes/frontend'));
23
        $finder->removeBasePath();
24
        $finder->setBasePath($basePath . DIRECTORY_SEPARATOR . $theme);
25
26
        config(['themes.frontend' => $theme]);
27
28
        return $next($request);
29
    }
30
}
31