Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
admin/src/SleepingOwl/Admin/AssetManager/AssetManager.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
59 lines (52 sloc)
1.16 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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)); | |
} | |
} |