-
Notifications
You must be signed in to change notification settings - Fork 259
/
Copy pathAssetManager.php
59 lines (52 loc) · 1.16 KB
/
AssetManager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php namespace SleepingOwl\Admin\AssetManager;
use AdminAuth;
use App;
use SleepingOwl\Admin\Admin;
use SleepingOwl\Admin\Router;
class AssetManager
{
/**
* Styles array to include on every admin page
* @var array
*/
protected static $styles = ['admin::all.min.css'];
/**
* Scripts array to include on every admin page
* @var array
*/
protected static $scripts = ['admin::all.min.js'];
public static function styles()
{
return static::assets(static::$styles);
}
public static function addStyle($style)
{
static::$styles[] = $style;
}
public static function scripts()
{
$scripts = static::assets(static::$scripts);
array_unshift($scripts, Admin::instance()->router->routeToLang(App::getLocale()));
return $scripts;
}
public static function addScript($script)
{
static::$scripts[] = $script;
}
/**
* @param $assets
* @return array
*/
protected static function assets($assets)
{
return array_map(function ($asset)
{
if (strpos($asset, 'admin::') !== false)
{
$asset = str_replace('admin::', '', $asset);
return Admin::instance()->router->routeToAsset($asset);
}
return $asset;
}, array_unique($assets));
}
}