I am using Dwoo template http://dwoo.org/ for my PHP project, and Dwoo allow me to create custom plugins. each plugin is stored inside php file, and Dwoo will be the one that handle the plugin lazy-loads.
But how one plugin can reuse another plugin? I can’t find anything on google about that, so I take a look at how
the compiled-code call plugin.
if (function_exists('Dwoo_Plugin_input')===false) {
$dwoo->getLoader()->loadPlugin('input');
}
Ah, simple! so my plugin can also use the same way to call another plugin. Here is the code for my ‘password’ plugin that is reusing ‘input’ plugin to generate HTML field
function Dwoo_Plugin_password(Dwoo $dwoo, array $rest = array()) {
if (function_exists('Dwoo_Plugin_input')===false) {
$dwoo->getLoader()->loadPlugin('input');
}
$rest['type'] = 'password';
$rest['autocomplete'] = 'off';
return Dwoo_Plugin_input($dwoo,$rest);
}
Dwoo FTW!
Advertisement
0 Responses to “Create Dwoo plugin that is reusing another plugin”