I implemented dynamic loading of plugins as follows:
function processPlugin( $plgFile, $db ) {
require_once( $plgFile );
$plgin = new PlginImpl();
$plgin->setDb($db);
$ret = $plgin->process();
return $ret;
}
Each plugin defines a class with a name PlginImplthat works great. But it should be possible to call additional plugins specified within the return value process(). This would invoke the same method above, but not with:
Fatal error: Cannot redeclare class PlginImpl in ..
Please note that each plugin is a class, namely:
class PlginImpl extends Plugin implements PluginInterface
PluginIt offers several useful features while PluginInterfacedetermines, for example process().
I assume that the fact that all plugins are called PlginImpl is causing a problem, so my question is: is there a way to unload class ( PlginImpl) after loading it from require_once? Or should I follow a completely different approach?
EDIT I tried without success the following things:$plgin after process()- call
__destruct()- it does not work either inside processPlugin()or inside the methodprocess
source
share