Skip to content

Commit

Permalink
Use new componentloader (#7)
Browse files Browse the repository at this point in the history
* Use `ComponentLoader`

* Add new init requirement to `README.md`

Co-authored-by: rvogel <[email protected]>
  • Loading branch information
osnard and rvogel authored Feb 7, 2022
1 parent e2c8c65 commit c829ee1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 30 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ The frequency of that job determines the minimum frequency at which handlers can

## Use in a MediaWiki extension

Add `"mwstake/mediawiki-component-runjobstrigger": "~1.0"` to the `require` section of your `composer.json` file.
Add `"mwstake/mediawiki-component-runjobstrigger": "~2.0"` to the `require` section of your `composer.json` file.

Since 2.0 explicit initialization is required. This can be archived by
- either adding `"callback": "mwsInitComponents"` to your `extension.json`/`skin.json`
- or calling `mwsInitComponents();` within you extensions/skins custom `callback` method

See also [`mwstake/mediawiki-componentloader`](https://github.com/hallowelt/mwstake-mediawiki-componentloader).

### Implement a handler

Expand Down
61 changes: 32 additions & 29 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,35 @@

define( 'MWSTAKE_MEDIAWIKI_COMPONENT_RUNJOBSTRIGGER_VERSION', '1.0.0' );

$GLOBALS['mwsgRunJobsTriggerOptions'] = [
"*" => [
"basetime" => [ 1, 0, 0 ],
"once-a-week-day" => "sunday"
]
];

$GLOBALS['mwsgRunJobsTriggerHandlerRegistry'] = [];

$GLOBALS['mwsgRunJobsTriggerHandlerFactories'] = [
'globalvars-config' => [
'class' => "\\MWStake\\MediaWiki\\Component\\RunJobsTrigger\\HandlerFactory\\GlobalVars"
],
'hook' => [
'class' => "\\MWStake\\MediaWiki\\Component\\RunJobsTrigger\\HandlerFactory\\Hook",
'services' => [ 'MainConfig' ]
]
];

$GLOBALS['mwsgRunJobsTriggerRunnerWorkingDir'] = sys_get_temp_dir();

$GLOBALS['wgJobClasses']['invokeRunner']
= "\\MWStake\\MediaWiki\\Component\\RunJobsTrigger\\Job\\InvokeRunner";

$GLOBALS['wgExtensionFunctions'][]
= "\\MWStake\\MediaWiki\\Component\\RunJobsTrigger\\Runner::runDeferred";

$GLOBALS['wgHooks']['LoadExtensionSchemaUpdates'][] = "\\MWStake\\MediaWiki\\Component\\"
. "RunJobsTrigger\\Hook\\LoadExtensionSchemaUpdates\\ClearJSONFiles::callback";
MWStake\MediaWiki\ComponentLoader\Bootstrapper::getInstance()
->register( 'runjobstrigger', function () {
$GLOBALS['mwsgRunJobsTriggerOptions'] = [
"*" => [
"basetime" => [ 1, 0, 0 ],
"once-a-week-day" => "sunday"
]
];

$GLOBALS['mwsgRunJobsTriggerHandlerRegistry'] = [];

$GLOBALS['mwsgRunJobsTriggerHandlerFactories'] = [
'globalvars-config' => [
'class' => "\\MWStake\\MediaWiki\\Component\\RunJobsTrigger\\HandlerFactory\\GlobalVars"
],
'hook' => [
'class' => "\\MWStake\\MediaWiki\\Component\\RunJobsTrigger\\HandlerFactory\\Hook",
'services' => [ 'MainConfig' ]
]
];

$GLOBALS['mwsgRunJobsTriggerRunnerWorkingDir'] = sys_get_temp_dir();

$GLOBALS['wgJobClasses']['invokeRunner']
= "\\MWStake\\MediaWiki\\Component\\RunJobsTrigger\\Job\\InvokeRunner";

$GLOBALS['wgExtensionFunctions'][]
= "\\MWStake\\MediaWiki\\Component\\RunJobsTrigger\\Runner::runDeferred";

$GLOBALS['wgHooks']['LoadExtensionSchemaUpdates'][] = "\\MWStake\\MediaWiki\\Component\\"
. "RunJobsTrigger\\Hook\\LoadExtensionSchemaUpdates\\ClearJSONFiles::callback";
} );
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"email": "[email protected]"
}
],
"require": {
"mwstake/mediawiki-componentloader": "~1"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "1.0.0",
"jakub-onderka/php-console-highlighter": "0.4.0",
Expand Down

0 comments on commit c829ee1

Please sign in to comment.