Files
2026-07-30 11:56:32 +03:00
..
2026-07-30 11:56:32 +03:00
2026-07-27 12:58:44 +03:00
2026-07-30 11:56:32 +03:00
2026-07-27 12:58:44 +03:00
2026-07-27 12:58:44 +03:00
2026-07-27 12:58:44 +03:00

Hooks and events

Hooks allow a module to interfere with the system's lifecycle without changing the kernel: check or supplement data, launch integration, clear your own cache or change the render result.

App\Helpers\Hooks is used for subscription. Most system events passing mutable object App\Common\LifecycleEvent; saving a document uses the specialized DocumentSaveEvent.

Section map

Page Destination
Subscription and context Manifest, priorities, LifecycleEvent, action/filter and custom events.
Saving documents Data and field changes, save rejection, publishing events.
Field Events Normalization, validation, recording and public rendering.
Event Catalog Complete list of stable kernel extension points.
Debugging and Reliability Public Debug, errors, performance and external services.

Basic rule

Declare a module subscription in its module.php, and place the handler in the class:

'hooks' => array(
    array(
        'name' => 'content.document.saved',
        'handler' => array(Subscriber::class, 'onDocumentSaved'),
        'priority' => 20,
    ),
),

The handler is not connected manually: classes are loaded by namespace-loader, subscription registers ModuleManager. Hooks from the public section only work on the site, from admin - only in the control panel, top-level ones - in both runtimes.

Don't use a hook as a hidden controller call. The context should be small predictable and documented, and long work needs to be taken out of critical HTTP request.