Hi all,
Looking at AutoLoader's __autoload() method, I see that the mappings
are kept in a static internal variable called $localClasses. Would
anyone have a problem with allowing this to be augmented by a global?
For example, say in LocalSettings or an extension you had:
$wgAutoloadClassMappings['Article'] =
'extensions/myextension/MyArticle.php';
And MyArticle extends Article, but with extra processing (presumably
something which can't currently be done with hooks).
Then, the code inside AutoLoader::__autoload() would contain something
like this:
------------
static $localClasses = array(
....
);
static $firstRun = true;
if ($firstRun) {
$firstRun = false;
global $wgAutoloadClassMappings;
if (!empty($wgAutoloadClassMappings)) {
$localClasses = array_merge( $localClasses, $wgAutoloadClassMappings );
}
}
------------
I think this could go a long way towards the goals of having a single
abstract factory pattern for object instantiation discussed previously
as the "Massive Hook Proposal".
I fully expect there's a better way to implement this than what's
proposed above. Any thoughts you have about this are much appreciated.
Thanks in advance.
-- Jim R. Wilson (jimbojw)