Implementation of the Assets Service
This release add support for the new Assets Service, and needs the Kernel version 4.0.58 or superior.
Notable changes
The Middleware for dispatching the asset files: Nova\Routing\Middleware\DispatchAssetFiles
was moved into namespace Nova\Assets\Middleware
and a new Service Provider: Nova\Assets\AssetServiceProvider
was added, then for upgrading to this application version, you should update your application configuration according.
The Helper Class Nova\Support\Assets
was replaced by the Nova\Assets\Manager
and its associated Facade Nova\Support\Facades\Asset
and offer a slightly different API.
In your Layout files, instead of Assets::css()
and Assets::js()
you should use and echoing the return value of Asset::build($type, $assets)
, for example:
Asset:css(array(
// Bootstrap 3.3.5
vendor_url('bower_components/bootstrap/dist/css/bootstrap.min.css', 'almasaeed2010/adminlte'),
// Bootstrap XL
asset_url('css/bootstrap-xl-mod.min.css', 'themes/admin-lite'),
// Font Awesome
vendor_url('bower_components/font-awesome/css/font-awesome.min.css', 'almasaeed2010/adminlte'),
// Ionicons
vendor_url('bower_components/Ionicons/css/ionicons.min.css', 'almasaeed2010/adminlte'),
// iCheck
vendor_url('plugins/iCheck/square/blue.css', 'almasaeed2010/adminlte'),
// Theme style
vendor_url('dist/css/AdminLTE.css', 'almasaeed2010/adminlte'),
// AdminLTE Skins
vendor_url('dist/css/skins/_all-skins.min.css', 'almasaeed2010/adminlte'),
// Custom CSS
asset_url('css/style.css', 'themes/admin-lite'),
));
should be replaced with:
echo Asset:build('css', array(
// Bootstrap 3.3.5
vendor_url('bower_components/bootstrap/dist/css/bootstrap.min.css', 'almasaeed2010/adminlte'),
// Bootstrap XL
asset_url('css/bootstrap-xl-mod.min.css', 'themes/admin-lite'),
// Font Awesome
vendor_url('bower_components/font-awesome/css/font-awesome.min.css', 'almasaeed2010/adminlte'),
// Ionicons
vendor_url('bower_components/Ionicons/css/ionicons.min.css', 'almasaeed2010/adminlte'),
// iCheck
vendor_url('plugins/iCheck/square/blue.css', 'almasaeed2010/adminlte'),
// Theme style
vendor_url('dist/css/AdminLTE.css', 'almasaeed2010/adminlte'),
// AdminLTE Skins
vendor_url('dist/css/skins/_all-skins.min.css', 'almasaeed2010/adminlte'),
// Custom CSS
asset_url('css/style.css', 'themes/admin-lite'),
));
Finally, the built-in support for @assets()
command within the Template Compiler was removed and you should use @php
commands to enclose the assets management code.
New features
The new Assets Service offer the ability to programmatically register assets in your bootstrap stage from application or modules, or even in Controllers, using a command like:
Assets::register('js', 'https://cdn.ckeditor.com/4.9.2/standard/ckeditor.js', 'footer');
OR, in case you use the Container to resolve the AssetManager on constructor:
$this->assets->register('js', 'https://cdn.ckeditor.com/4.9.2/standard/ckeditor.js', 'footer');
Where the first argument is the asset type, the second is the asset(s) and the third one is the position.
These commands, for working, imply that you have added in your Layout Views the following code:
<?= Assets::render('js', 'footer'); ?>
Where the first argument is the asset type and the second one is the position.
To note that the default and example Layout Views will accept two positions for JavaScript assets: header
and footer
and obviously only the header
position for CSS ones.