Extension:RandomGameUnit/Hooks/RandomGameUnit
RandomGameUnit | |
---|---|
Available from version ??? |
|
Define function: | public static function onRandomGameUnit( &$random_games, &$custom_fallback ) { ... }
|
Attach hook: | $wgHooks['RandomGameUnit'][] = 'MyExtensionHooks::onRandomGameUnit';
|
Called from: | File(s): Category:Extension hooks provided by RandomGameUnitRandomGameUnit / includes/RandomGameUnit.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of other extensions using this hook, see Category:RandomGameUnit extensions.
The RandomGameUnit hook, provided by the extension with the same name, allows adding a new type of random casual game that RandomGameUnit can pick, in addition to the three "built-in" types of games: polls (provided by Extension:PollNY), picture games (provided by Extension:PictureGame) and quizzes (provided by Extension:QuizGame).
It is also theoretically possible for a hook subscriber to remove items from the $random_games
array or even set it to a blank array, which would then force the <randomgameunit>
tag to return an empty string.
The only extension that ever sorta used this hook is the ArmchairGM-specific PickGame extension (directory name "SportsGames"). This is basically how it used it:
public static function onRandomGameUnit( &$random_games, &$custom_fallback ) {
$random_games[] = 'custom';
$custom_fallback = 'PickGameUnit::displayPickGameUnit';
return true;
}
The callback method (PickGameUnit::displayPickGameUnit
in this example) would then handle the logic of picking an appropriately random "custom" game unit for the current user and return its HTML.