AssetHandler
The AssetHandler
class is responsible for managing and rendering various types of assets (such as CSS links and JavaScript files) in your application. It supports adding, retrieving, and rendering assets, as well as handling assets loaded from an array. The class is designed to be modular, allowing it to work with different asset types, such as LinkAsset and ScriptAsset.
Example Usage of AssetHandler
$linkAsset = new LinkAsset("stylesheet");
$linkAsset->setParams([
"rel" => "stylesheet",
"href" => "{QUANTA_DOMAIN}/assets/styles.css"
]);
$quanta->assetHandler->addAsset($linkAsset);
Example of Rendering a Asset
echo $quanta->renderAsset("stylesheet");
Conclusion
The AssetHandler class is a powerful utility that allows you to manage and render different types of assets in a clean, modular way. Whether you're dealing with CSS links or JavaScript scripts, this system enables seamless integration and rendering of assets across your application. By supporting the dynamic loading of assets and the rendering of HTML tags based on parameters, Quanta’s asset management system ensures flexibility and scalability for your web applications.