Path in the Gestor bibliotecas/hooks.php
Always loaded by config.php. How it works (JSON declaration, the hooks table, ordering and the event catalog) is in Hooks: actions and filters. This page is only the API reference.
Firing
| Function | |
|---|---|
hook_do_action($namespace, $event, ...$args) |
Runs the actions. No return value |
hook_apply_filters($namespace, $event, $value, ...$args) |
Passes $value through each filter and returns the result |
hook_has_actions($namespace, $event) / hook_has_filters(…) |
true if something is registered (including in the * namespace) |
They all delegate to the HookManager (singleton), which loads from the database on the first lookup of each namespace.event and memoizes per request.
Registering (pipeline use)
| Function | |
|---|---|
hooks_registrar_modulo($module, $plugin, $config) |
Deletes the module's hooks and reinserts the ones in the JSON hooks section |
hooks_registrar_projeto() |
The same for project/hooks/hooks.json (records with projeto=1) |
hooks_inserir_callbacks(…) |
Normalizes the three callback forms (string, object, list) and writes them |
Do not call these functions in a regular request: they rewrite the table. They are called by atualizacoes_hooks_sincronizar(), at the end of the database updater and of the deploy.
Functions
Generated from gestor/bibliotecas/hooks.php · 7 functions
hook_do_action
view source · line 363 ↗hook_do_action(string $namespace, string $evento, mixed ...$args): voidExecuta todos os callbacks de action para um namespace+evento.
Parameters
$namespacestring- Namespace alvo (ex: 'paginas', 'global')
$eventostring- Evento específico (ex: 'editar', 'adicionar')
$argsmixed- Argumentos passados para os callbacks
Returns
hook_apply_filters
view source · line 376 ↗hook_apply_filters(string $namespace, string $evento, mixed $value, mixed ...$args): mixedAplica todos os filters para um namespace+evento, retornando o valor transformado.
Parameters
$namespacestring- Namespace alvo
$eventostring- Evento específico
$valuemixed- Valor a ser filtrado
$argsmixed- Argumentos adicionais
Returns
hook_has_actions
view source · line 383 ↗hook_has_actions(string $namespace, string $evento): boolVerifica se existem actions registradas para um namespace+evento.
Parameters
$namespacestring$eventostring
Returns
hook_has_filters
view source · line 390 ↗hook_has_filters(string $namespace, string $evento): boolVerifica se existem filters registrados para um namespace+evento.
Parameters
$namespacestring$eventostring
Returns
hooks_registrar_modulo
view source · line 407 ↗hooks_registrar_modulo(string $modulo, ?string $plugin, array $hooks_config): intRegistra/atualiza os hooks de um módulo na tabela hooks. Remove hooks antigos do módulo que não estão mais no JSON. Fonte de verdade: arquivo JSON do módulo.
Parameters
$modulostring- ID do módulo
$plugin?string- ID do plugin (null se não for de plugin)
$hooks_configarray- Seção "hooks" do JSON do módulo
Returns
hooks_registrar_projeto
view source · line 440 ↗hooks_registrar_projeto(): intRegistra/atualiza os hooks do projeto (project/hooks/hooks.json). Remove hooks de projeto antigos e re-insere os do JSON atual.
Returns
hooks_inserir_callbacks
view source · line 493 ↗hooks_inserir_callbacks(?string $modulo, ?string $plugin, string $namespace, string $evento, mixed $callbackDef, string $tipo, ?int $projeto): intInsere callback(s) na tabela hooks. Suporta: string simples, array de strings, ou objeto {callback, prioridade, habilitado}.
Parameters
$modulo?string$plugin?string$namespacestring$eventostring$callbackDefmixed- Definição do callback (string, array, ou assoc array)
$tipostring- 'action' ou 'filter'
$projeto?int- 1 se de projeto, null se de módulo
Returns