Passed
Branch main (b90ec4)
by Thierry
20:23 queued 14:04
created

TontineTemplate   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 1
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Http\RedirectResponse;
7
use Illuminate\Http\Request;
8
use Illuminate\Http\Response;
9
use Illuminate\Support\Facades\View;
10
11
use function config;
12
use function Jaxon\jaxon;
13
use function resource_path;
14
15
class TontineTemplate
16
{
17
    /**
18
     * Handle an incoming request.
19
     *
20
     * @param  Request  $request
21
     * @param  Closure(Request): (Response|RedirectResponse)  $next
22
     *
23
     * @return Response|RedirectResponse
24
     */
25
    public function handle(Request $request, Closure $next)
26
    {
27
        $template = config('tontine.templates.app', 'default');
28
        $tontinePath = resource_path("views/tontine/app/$template");
29
        $paginationPath = "$tontinePath/parts/table/pagination";
30
        View::addNamespace('tontine', $tontinePath);
31
32
        // Register the namespaces in the Jaxon view renderer.
33
        $jaxonView = jaxon()->view();
34
        $jaxonView->addNamespace('tontine', $tontinePath, '.blade.php', 'blade');
35
        $jaxonView->addNamespace('pagination', $paginationPath, '.blade.php', 'blade');
36
37
        return $next($request);
38
    }
39
}
40