class hook_manager implements hook_manager_interface

Lightweight Hook Manager (WordPress style).

Handles synchronous execution of filters and actions. Registration is handled by individual Extensions during boot.

Methods

static void
add_filter(string $tag, callable $function, int $priority = 10, int $args = 1)

Register a new filter callback.

static mixed
apply_filters(string $tag, mixed $value, mixed ...$args)

Apply all filter callbacks registered for a given tag.

static void
add_action(string $tag, callable $function, int $priority = 10, int $args = 1)

Register a new action callback.

static void
do_action(string $tag, mixed ...$args)

Execute all action callbacks registered for a given tag.

static bool
has_action(string $tag)

Check if any action has been registered for a hook.

static void
reset()

Clear all registered hooks. Essential for unit testing isolation.

Details

at line 44
static void add_filter(string $tag, callable $function, int $priority = 10, int $args = 1)

Register a new filter callback.

Parameters

string $tag

Filter identifier

callable $function

Callback to execute

int $priority

Lower = run earlier

int $args

Number of accepted arguments

Return Value

void

at line 64
static mixed apply_filters(string $tag, mixed $value, mixed ...$args)

Apply all filter callbacks registered for a given tag.

Each callback receives the current value and must return a (possibly modified) value.

Parameters

string $tag

Filter identifier

mixed $value

Initial value

mixed ...$args

Additional parameters passed to callbacks

Return Value

mixed

Filtered value

at line 92
static void add_action(string $tag, callable $function, int $priority = 10, int $args = 1)

Register a new action callback.

Parameters

string $tag

Action identifier

callable $function

Callback to execute

int $priority

Lower = run earlier

int $args

Number of accepted arguments

Return Value

void

at line 108
static void do_action(string $tag, mixed ...$args)

Execute all action callbacks registered for a given tag.

Unlike filters, actions do not return values.

Parameters

string $tag

Action identifier

mixed ...$args

Parameters passed to callbacks

Return Value

void

at line 128
static bool has_action(string $tag)

Check if any action has been registered for a hook.

Parameters

string $tag

Return Value

bool

at line 136
static void reset()

Clear all registered hooks. Essential for unit testing isolation.

Return Value

void