Conn2Flow
Docs navigation

Reference / Libraries

hooks.php library

Hooks API reference: hook_do_action, hook_apply_filters, hook_has_* and the registration functions used by the pipeline.

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

7 of 7

hook_do_action

view source · line 363 ↗
hook_do_action(string $namespace, string $evento, mixed ...$args): void

Executa 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

void

hook_apply_filters

view source · line 376 ↗
hook_apply_filters(string $namespace, string $evento, mixed $value, mixed ...$args): mixed

Aplica 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

mixed
Valor após aplicação de todos os filters

hook_has_actions

view source · line 383 ↗
hook_has_actions(string $namespace, string $evento): bool

Verifica se existem actions registradas para um namespace+evento.

Parameters

$namespacestring
$eventostring

Returns

bool

hook_has_filters

view source · line 390 ↗
hook_has_filters(string $namespace, string $evento): bool

Verifica se existem filters registrados para um namespace+evento.

Parameters

$namespacestring
$eventostring

Returns

bool

hooks_registrar_modulo

view source · line 407 ↗
hooks_registrar_modulo(string $modulo, ?string $plugin, array $hooks_config): int

Registra/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

int

hooks_inserir_callbacks

view source · line 493 ↗
hooks_inserir_callbacks(?string $modulo, ?string $plugin, string $namespace, string $evento, mixed $callbackDef, string $tipo, ?int $projeto): int

Insere 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

int

The Future is Hybrid: Human + AI.

Conn2Flow is the tool. If you need the Architect to design your company's strategy using this technology...

Hire Specialized Consulting