Modèle:MediaWikiHook

This page is a translated version of the page Template:MediaWikiHook and the translation is 88% complete.
Documentation du modèle

Copier/coller le modèle

MyHook
Disponible depuis version ???

Fonction à définir :
public static function onMyHook( $x, $y ) { ... }
Attacher l'accroche : Dans extension.json :
{
	"Hooks": {
		"MyHook": "MediaWiki\\Extension\\MyExtension\\Hooks::onMyHook"
	}
}
Appelé de : Fichier(s) :
Interface : MyHookHook.php

Pour plus d'information sur l'ajout des accroches (hooks), voir Accroches .
Pour des exemples d'extensions utilisant cette accroche, voir Category:MyHook extensions/fr .

{{MediaWikiHook
|name = MyHook
|version =
|gerrit =
|gerritremoved =
|removed =
|summary =
|args = $x, $y
|source =
|sourcefunction =
|sourceclass =
|newvarname =
|newvarlink =
|nocatdesc =
}}

Notes d'utilisation

[voir · discuter · modifier]

Ceci est la documentation de TemplateData pour ce modèle, utilisée par VisualEditor et autres outils.

MediaWikiHook

A card which describes the information of a MediaWiki-registered hook.

Template parameters[Edit template data]

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Template modetemplatemode

Set to nocats if hook documentation should not appear in standard MediaWiki Categories. By default, using this template places the documentation page into categories: MediaWiki hooks Hooks added in MediaWiki... There are times when it is undesirable to automatically categorize the hook documentation. Examples would include when documenting a hook in an extension, or when documenting the template itself.

Stringoptional
Namename

The name of the hook. This is usually the same name as the sub-page.

Stringoptional
Versionversion

The version of MediaWiki this hook was first introduced in. Should always be a full version number (ie. ending with ".0").

Example
1.35.0
Stringsuggested
Version removedremoved

If the hook has been removed, the version of MediaWiki that it was removed in.

Stringoptional
Message for removed hookremoved-msg

If it is not suitable to use either the "newvarname" or the "newvarlink" template parameter, use this parameter. This parameter can be used to explain why it was removed, or for example, explain why there is no suitable replacement.

Stringoptional
Version deprecateddeprecated

If the hook has been deprecated (but not removed), the version of MediaWiki that it was deprecated in.

Stringoptional
Message for deprecated hookdeprecated-msg

If it is not suitable to use either the "newvarname" or the "newvarlink" template parameter, use this parameter. This parameter can be used to explain why it was removed, or for example, explain why there is no suitable replacement.

Stringoptional
New variable namenewvarname

For removed or deprecated hooks, the name of the hook that should be used instead

Stringoptional
New variable linknewvarlink

For removed or deprecated hooks, the link to the hook that should be used instead

Page nameoptional
SVN revision introducedrev

SVN revision in which this hook was first introduced. If this parameter is given, it'll link to the appropriate CodeReview page (e.g. [[phabricator:rSVN1]]).

Example
[[phabricator:rSVN1]]
URLoptional
Gerrit changesetgerrit

Gerrit change number in which this hook was first introduced. If this parameter is given, it'll link to the appropriate Gerrit changeset page (e.g. Gerrit change 1)

Numbersuggested
Gerrit changeset removedgerritremoved

Gerrit change number in which this hook was removed. If this parameter is given, it'll link to the appropriate Gerrit changeset page (e.g. Gerrit change 1)

Numberoptional
Summarysummary

A short description of the hook's purpose. More detailed descriptions are desirable, and should be added to the main page content. If you update the short description, please also update the two tables on [[Special:MyLanguage/Manual:Hooks]].

Stringrequired
Argumentsargs

The arguments, as used at the top of the function.

Stringrequired
extensionextension

The extension which defines this hook.

Stringoptional
File source 1source

Location (file name/path not including <code>includes/</code>) which calls this hook in the code. Further locations can be added via source2...source10.

Filesuggested
File source 2source2

see source

Fileoptional
File source 3source3

see source

Fileoptional
File source 4source4

see source

Fileoptional
File source 5source5

see source

Fileoptional
File source 6source6

see source

Fileoptional
File source 7source7

see source

Fileoptional
File source 8source8

see source

Fileoptional
File source 9source9

see source

Fileoptional
File source 10source10

see source

Fileoptional
Function source 1sourcefunction

Name of the function which calls this hook. Another can be added via sourcefunction2.

Stringsuggested
Function source 2sourcefunction2

see sourcefunction

Stringoptional
Class sourcesourceclass

Name of the class which calls this hook.

Stringsuggested
nocatdescnocatdesc

If a hook is removed completely from MediaWiki version by setting yes, it will not show up the category description.

Stringoptional

Chercher la version d'une accroche et l'ID de Gerrit

Pour initialiser les attributs version et gerrit de ce modèle, vous pourriez avoir besoin de chercher l'historique du fichier docs/hooks.txt.

  1. (A partir de la racine d'un clone Git du code source de MediaWiki)
  2. Chercher la plus ancienne validation de hooks.txt qui mentionne cette accroche :
    • git grep <nom de l'accroche, ici> $(git rev-list --all -- docs/hooks.txt) -- docs/hooks.txt | tail -n 1
  3. Trouver son ID Gerrit :
    • git log <la validation ci-dessus>
    1. Copier l'ID de la modification à partir de l'entrée du journal vers la boîte de recherche de Gerrit
    2. Sélectionnez la modification adéquate, et obtenez son ID
  4. Trouver dans quelle version l'accroche est apparue pour la première fois :
    • git tag --contains <la validation ci-dessus>

Categories

The template automatically adds the page to the following categories:

  • Category:Hooks added in MediaWiki <version>
  • Category:MediaWiki hooks included in <file>

and links to the following category:

  • Category:<hook name> extensions

When creating a new hook documentation page, you should create this categories if they don't exist yet. The first two can be left with an empty body; the third one should contain {{HookUsage|<name>}}.