Dear Wiki Devs,
I have a proposal for adding new hooks into the MW codebase, and I'm looking for feedback (positive and negative). The goal of the proposed changes is to give Extension Devs the ability to cleanly hijack just about any class in the system. Here are the details:
Step 1: For each class in MW, create a static factory method for class instantiation. The factory method would take the same number of arguments as the class constructor, and under normal circumstances would simply call the constructor. Here's an example for the UploadForm class ( SpecialUpload.php):
-------------------------------------------------------------- class UploadForm {
// ...
function instantiate( &$request ) { $uploadForm = new UploadForm($request); wfRunHooks('UploadFormInstantiate', array( &$uploadForm, &$request )); return $uploadForm; } --------------------------------------------------------------
Step 2: Replace all calls to the traditional "new Whatever($args)" with "Whatever::instantiate($args)".
By doing this, extension developers gain the power to modify any class before it's ever used, possibly even replacing it with a custom class they've developed.
What do you think? I'm genuinely interested in hearing what everyone has to say. Thanks!
(Please note that I haven't tested any code for this yet - so if my syntax in the example is out of order, I apologize in advance).
-- Jim R. Wilson