Hooks

Hooks are a powerful tool that allow your component to 'hook into' the Nestor engine at various stages of the Page Build process, as well as any place in the code where a hook has been inserted. A hook is configured within a component class and designates a class and method to call when the hook is invoked within the system. In the Nestor system, a class/method pairing is known as a procedure.

During the Page Build process, the procedure/hook associations are loaded into a hooks array that’s added to the global $site object. The Hooks Definition and Load Process flow chart shows the end-to-end process of defining a hook and loading into the system for use.

Read the Add a Hook section in Extended Component Development to learn how to associate a procedure with a hook in the Nestor system.

Hooks invoked during the Page Build Process

The following flow charts depict when the major system hooks are invoked during the Page Build process. You can use these charts to design your own component hooks if you need to influence the build process at any point. Hooks are shown as green boxes. Note that some hooks receive parameters to route to the designated procedures, and some change the value of passed parameters and send the changed value back into the method from which the hook is invoked. Each hook representation in the flow chart details how parameters are processed by the hook procedure.

  1. Page Build process – shows the high level process, hooks displayed are invoked during the instantiation of the $site, $user and $page objects.
  2. Build Component Array process – shows the detailed process of building the component array, with hooks invoked by get_components and get_subcomponents methods of the Page class.
  3. Build Content process – depicts the hooks invoked during the complex interaction between classes (primarily Page and Component) to render the page content.

Hooks defined in the Core Engine Classes

The following section lists the hooks found in core engine classes, as well as some other standard component classes. Each hook should follow a standard nomenclature to make it easier to trace their origin and function:

[Class-name]_[method-name]_[brief-description]

This list is not exhaustive for the entire system, as any Component has the ability to create hooks.

at_user_login

at_user_logout

alternative_user_login

create_component_before

delete_extirpate_component

input_sanitize_textarea

media_after_display

media_before_display

media_create_component

media_component_created

media_file_uploader

media_update_component

media_delete_component

page_add_recipe

page_build_content

page_build_content_callback

page_construct_object

page_get_components

page_get_sub_components

page_requested_components

page_requested_components

page_requested_url

recipe_attributes

recipe_components_each

requested_sub_components

site_hook_initiation

site_javascript_dependencies

site_mail_transport

site_media_link

site_object_construct

user_attributes