WpHostEventBridge
in package
implements
HostEventBridgeInterface
WordPress host event bridge.
Implements the framework's platform-agnostic HostEventBridgeInterface
seam by exposing the host's NATIVE eventing — named events become WordPress
action hooks, so add_action() consumers anywhere in the site (satellite
plugins, themes) hear governed events without importing MIDDAG code:
dispatch('quote.created', [$quote]) → do_action('acme/quote.created', $quote)
listen('quote.created', $callback) → add_action('acme/quote.created', $callback)
(with the hook prefix acme/).
This is the WordPress counterpart of MoodleHostEventBridge, which delegates
to the framework's in-memory HookManager
instead — WordPress already has the hooks API this contract describes, so the
adapter goes native. The payload is spread as positional arguments (keys are ignored).
The hook prefix is a constructor argument. Its default is the neutral
library marker middaglib/, which names no product: a consumer passes the
prefix of its own public hook surface in its composition root.
Table of Contents
Interfaces
- HostEventBridgeInterface
Properties
- $hookPrefix : string
Methods
- __construct() : mixed
- dispatch() : void
- listen() : void
- hook() : string
Properties
$hookPrefix
private
string
$hookPrefix
= 'middaglib/'
Methods
__construct()
public
__construct([string $hookPrefix = 'middaglib/' ]) : mixed
Parameters
- $hookPrefix : string = 'middaglib/'
dispatch()
public
dispatch(string $eventName[, array<string|int, mixed> $payload = [] ]) : void
Parameters
- $eventName : string
- $payload : array<string|int, mixed> = []
listen()
public
listen(string $eventName, callable $listener[, int $priority = 10 ]) : void
Parameters
- $eventName : string
- $listener : callable
- $priority : int = 10
hook()
private
hook(string $eventName) : string
Parameters
- $eventName : string