The asset manager in AsgardCms is a helper to let you load assets faster without making you look at the filesystem to find assets. It is important to note that the asset manager is not a requirement, you can choose not to use it if you wish.
Asgard Asset Manager is a 2 part package. First there is the manager in which you add all the assets you will need to build your site. This doesn't mean those assets will be included in all files, it merely means they will be ready for the asset pipeline to require them on the page.
You can add assets on the manager using two different ways:
First and easiest way is to add assets in the config/asgard.core.core.php config file, in the admin-assets key. Those will be added onto the manager.
The second way is to manually calling the AssetManager in a class somewhere. You can do this by injecting the Modules\Core\Foundation\Asset\Manager\AssetManager interface and using the following methods:
* Add a possible asset
* @param string $dependency
* @param string $path
* @return void
public function addAsset($dependency, $path);
* Add an array of possible assets
* @param array $assets
* @return void
public function addAssets(array $assets);
As you can see you can either pass a dependency name and its path to addAsset, or by sending an array to addAssets. That array needs to have as key the dependency name and value the path to that dependency.
After adding all possible dependencies on the asset manager, you are ready to require them on a page.
As you might already have seen, in the config/asgard.core.core.php file there is a admin-required-assets (which calls all assets by its name defined on the asset manager). This key sets all default assets that will always be included on the AdminLTE theme.
If a particular view needs a couple more assets, you can define those in the controller method that handles that view.
For instance a Page Edit view, needs CkEditor and a css file for the iCheck jQuery plugin. Those are not loaded on every view.
To add them onto the view I call these methods to require those assets: