The Extension Hooks
You can use the following Hook
constants to refer to
the hooks in your extensions. The hooks are called in the following
order (except for ERROR
, which may of course be
called at any point):
INIT
-
This hook is called immediately after a request is received by the Waiter. The hook object is empty.
AFTER_CONTEXT_RESOLVED
-
This hook is called once the Waiter has determined which publication the request is directed to. The following items have been added to the hook object:
currentPageUrl
-
The URL of the requested page.
contextPublication
-
An object containing information about the publication to which the requested page belongs.
BEFORE_COOK_REQUEST
-
This hook is called when the request is ready to be forwarded to the Cook. The following items have been added to the hook object:
cookURL
-
The URL of the Cook to which the request is to be forwarded.
requestOptions
-
The request headers to be sent to the Cook with the request.
AFTER_COOK_REQUEST
-
This hook is called immediately after a response is received from the Cook. The following item has been added to the hook object:
response
-
The response returned by the Cook.
AFTER_TWIG_ENVIRONMENT_READY
-
This hook is called once the Waiter has prepared the Twig environment for processing the response. The following item has been added to the hook object:
twig
-
An object containing the Twig environment for processing the response.
BEFORE_TEMPLATE_RENDER
-
This hook is called immediately before the response is sent for rendering by Twig. The following item has been added to the hook object:
response
-
The final response, as prepared by the Waiter. It overwrites the earlier value of response added by the
AFTER_COOK_REQUEST
hook.
ERROR
-
This hook can be called at any time if an error occurs. The following item has been added to the hook object:
error
-
The exception object.