Completed
Push — master ( cdd4df...1c7dfc )
by Song
02:45
created

Bootstrap::injectFormAssets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Middleware;
4
5
use Encore\Admin\Admin;
6
use Encore\Admin\Form;
7
use Encore\Admin\Grid;
8
use Illuminate\Http\Request;
9
10
class Bootstrap
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function handle(Request $request, \Closure $next)
16
    {
17
        Form::registerBuiltinFields();
18
19
        Grid::registerColumnDisplayer();
20
21
        if (file_exists($bootstrap = admin_path('bootstrap.php'))) {
22
            require $bootstrap;
23
        }
24
25
        $this->injectFormAssets();
26
27
        return $next($request);
28
    }
29
30
    /**
31
     * Inject assets of all form fields.
32
     */
33
    protected function injectFormAssets()
34
    {
35
        $assets = Form::collectFieldAssets();
36
37
        Admin::css($assets['css']);
38
        Admin::js($assets['js']);
39
    }
40
}
41