![]() ![]() With the introduction of per-hook interfaces, the canonical names of these hooks have been changed to use underscores instead. Prior to MediaWiki 1.35, hooks sometimes included characters that could not be used in a class or method name, such as colons and dashes. To learn more, see the MediaWiki core: Hook specification and the announcement on wikitech-l. Extension authors may opt-in to the new system are welcome to do so. The approach from MediaWiki 1.34 and earlier, of registering hook handlers directly as static methods, remains supported and is not deprecated. It also enables dependency injection by introducing an intermediary class instance that accepts a number of specified services (instead of static callbacks that explicitly access services from global state). This includes per-hook interfaces for improved static validation and discovery of parameter documentation. MediaWiki 1.35 introduces the HookHandlers system. Lastly, don't forget to add them to Category:Extension hooks. You can then run your hook within your extension by calling Hooks :: run ( 'HookName', ). It is registered in extension.json the same way as if you were registering a built-in MediaWiki hook to use in your extension. You can also create new hooks in your own extension. For extensions, if the hook function's behavior is conditioned on a setting in LocalSettings.php, the hook should be assigned and the function should terminate early if the condition was not met. Each hook can have multiple handlers assigned to it, in which case it will call the functions in the order that they are assigned, with any modifications made by one function passed on to subsequent functions in the chain.Īssign functions to hooks at the end of LocalSettings.php or in your own extension file at the file scope ( not in a $wgExtensionFunctions function or the ParserFirstCallInit hook). Assigning a function (known as an hook handler) to a hook will cause that function to be called at the appropriate point in the main MediaWiki code, to perform whatever additional task(s) the developer thinks would be useful at that point. ![]() MediaWiki provides many hooks like this to extend the functionality of the MediaWiki software. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |