Predefinição:MediaWikiHook
Predefinição para copiar e colar
MyHook | |
---|---|
Disponível a partir da version ??? |
|
Função de definição: |
public static function onMyHook( $x, $y ) { ... }
|
Anexar hook: |
Na extension.json: {
"Hooks": {
"MyHook": "MyExtensionHooks::onMyHook"
}
}
|
Chamado a partir de: | Arquivo(s): |
Interface: | MyHookHook.php |
Para mais informações sobre anexar hooks, consulte Manual:Ganchos .
Para exemplos de extensões que usam este hook, consulte Category:MyHook extensions/pt-br.
{{MediaWikiHook |name = MyHook |version = |gerrit = |removed = |summary = |args = $x, $y |source = |sourcefunction = |sourceclass = |newvarname = |newvarlink = }}
Notas de uso
A card which describes the information of a MediaWiki-registered hook.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Template mode | templatemode | 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. | Unknown | optional |
Name | name | The name of the hook. This is usually the same name as the sub-page. | Unknown | optional |
Version | version | The version of MediaWiki this hook was first introduced in. | Unknown | suggested |
Version removed | removed | If the hook has been removed, the version of MediaWiki that it was removed in. | String | optional |
Message for removed hook | removed-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. | String | optional |
Version deprecated | deprecated | If the hook has been deprecated (but not removed), the version of MediaWiki that it was deprecated in. | Unknown | optional |
Message for deprecated hook | deprecated-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. | String | optional |
New variable name | newvarname | For removed or deprecated hooks, the name of the hook that should be used instead | Unknown | optional |
New variable link | newvarlink | For removed or deprecated hooks, the link to the hook that should be used instead | Unknown | optional |
SVN revision introduced | rev | 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]]). | Unknown | optional |
Gerrit changeset | gerrit | 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) | Unknown | suggested |
Summary | summary | A short description of the hook's purpose. More detailed descriptions are desirable, and should be added to the main page content. | Unknown | required |
Arguments | args | The arguments, as used at the top of the function. | Unknown | required |
Extension | extension | no description | Unknown | optional |
File source | source | Location (file name/path not including <code>includes/</code>) which calls this hook in the code. Further locations can be added via source2...source10. | Unknown | suggested |
File source 2 | source2 | no description | Unknown | optional |
File source 3 | source3 | no description | Unknown | optional |
File source 4 | source4 | no description | Unknown | optional |
File source 5 | source5 | no description | Unknown | optional |
File source 6 | source6 | no description | Unknown | optional |
File source 7 | source7 | no description | Unknown | optional |
File source 8 | source8 | no description | Unknown | optional |
File source 9 | source9 | no description | Unknown | optional |
File source 10 | source10 | no description | Unknown | optional |
Function source | sourcefunction | Name of the function which calls this hook. Another can be added via sourcefunction2. | Unknown | suggested |
Function source 2 | sourcefunction2 | no description | Unknown | optional |
Class source | sourceclass | Name of the class which calls this hook. | Unknown | suggested |
- name
- Nome do hook. Geralmente o mesmo que o da sub-página.
- version
- Versão do MediaWiki na qual o hook foi lançado.
- rev
- Revisão do SVN na qual o hook foi lançado. Se esse parâmetro for fornecido, ele criará uma ligação à página do CodeReview (p. ex., phabricator:rSVN1).
- gerrit
- Número da mudança no Gerrit no qual o hook foi lançado. Se esse parâmetro for fornecido, ele criará uma ligação à página de changeset no Gerrit (p. ex., Mudança 1 do Gerrit)
- removed
- Se o hook foi removido, especificar a versão do MediaWiki na qual isso aconteceu.
- deprecated
- Se o hook foi depreciado (mas não removido), a versão do MediaWiki na qual isso aconteceu.
- summary
- Descrição rápida do propósito do hook.
- Claro que descrições mais detalhadas são úteis, mas devem ser adicionadas à página principal do hook.
- Se a descrição rápida for atualizada, atualize também as duas tabelas em Manual:Ganchos .
- args
- Argumentos da função.
- source
- Locação (nome do arquivo) que chama o hook no código. Outras locações podem ser adicionadas de
source2
asource10
.
- sourcefunction
- Nome das funções pelas quais o hook é chamado.
- sourceclass
- Nome da classe pela qual o hook é chamado.
- templatemode
- Defina como nocats caso a documentação do hook não deva aparecer nas categorias padrões do MediaWiki.
- Por padrão, a transclusão dessa predefinição adiciona a página de documentação às categorias:
- MediaWiki hooks (/pt-br)
- Hooks added in MediaWiki… (/pt-br)
- Algumas vezes, deseja-se não categorizar automaticamente a documentação do hook. Exemplos para isso podem ser ao documentar um hook numa extensão ou ao documentar a própria predefinição.
Encontrando a versão do hook e o ID do Gerrit
Para popular os atributos version
e gerrit
da predefinição, será necessário encontrar o histórico do arquivo docs/hooks.txt.
- (A partir do nível-topo (principal) de um clone do Git do código-fonte do MediaWiki)
- Encontre o commit mais antigo ao
hooks.txt
que mencione o hook:git grep <nome-do-hook-aqui> $(git rev-list --all -- docs/hooks.txt) -- docs/hooks.txt | tail -n 1
- Encontre o ID do Gerrit:
git log <o-commit-da-etapa-anterior>
- Copie o
change-id
do registro na caixa de pesquisa do Gerrit - Selecione a mudança relevante, e nela estará o ID
- Encontre a release na qual o hook foi lançado:
git tag --contains <aquele-mesmo-commit>