Middleware

Provides an API for extending HotMelt's request handling machinery.

Middleware can register for hooks to intercept requests.

Methods

Initialize a middleware instance.

__construct() 

The default implementation does not take any arguments.

Loads middleware definitions from the site directory.

registerMiddleware() : void
static

Registers a callback function for a hook.

registerHook(string $name, callable $callback) : void
static final

You must only call this function from within the register() method of your middleware subclass. Strictly speaking the middleware hook facility is not limited to subclasses of \HotMelt\Middleware. Note, however, that registering a callback through this function in any other context than the register() method is not officially supported.

Arguments

$name

string

The hook to register for.

$callback

callable

The callback to execute for the hook.

Executes all callbacks registered for a given hook.

executeHook(string $name) : array
static final

Additional parameters passed to this method are passed on to registered callbacks.

Arguments

$name

string

The name of hook for which to execute registered callbacks.

Response

array

The data accumulated by executing all registered callbacks.

Add a middleware component by name.

add(string $name) 
static final

Additional parameters passed to this method are passed on to the middleware constructor.

Arguments

$name

string

The class name of the middleware to add.