Callbacks

Introduction

There are a number of callbacks available in the Streams Platform designed to help you extend core functionality.

Addon Callbacks

Registered

The registered callback fires immediately after the addon is registered but before the addon boot process which follows the register process.

$module->on('registered', function() {
    // Do something after registering.
});

Addon Management

Module Installing

The installing callback is fired after a module is installing. The installing module is passed to the callback.

$module->on('installing', function() {
    // Do something before installing.
});

Module Installed

The installed callback is fired after a module is installed. The installed module is passed to the callback.

$module->on('installed', function() {
    // Do something after installing.
});

Module Uninstalling

The uninstalling callback is fired after a module is uninstalling. The uninstalling module is passed to the callback.

$module->on('uninstalling', function() {
    // Do something before uninstalling.
});

Module Uninstalled

The uninstalled callback is fired after a module is uninstalled. The uninstalled module is passed to the callback.

$module->on('uninstalled', function() {
    // Do something after uninstalling.
});

Module Migrating

The migrating callback is fired after a module is migrating. The migrating module is passed to the callback.

$module->on('migrating', function() {
    // Do something before migrating.
});

Module Migrated

The migrated callback is fired after a module is migrated. The migrated module is passed to the callback.

$module->on('migrated', function() {
    // Do something after migrating.
});

Extension Installing

The installing callback is fired after a extension is installing. The installing extension is passed to the callback.

$extension->on('installing', function() {
    // Do something before installing.
});

Extension Installed

The installed callback is fired after a extension is installed. The installed extension is passed to the callback.

$extension->on('installed', function() {
    // Do something after installing.
});

Extension Uninstalling

The uninstalling callback is fired after a extension is uninstalling. The uninstalling extension is passed to the callback.

$extension->on('uninstalling', function() {
    // Do something before uninstalling.
});

Extension Uninstalled

The uninstalled callback is fired after a extension is uninstalled. The uninstalled extension is passed to the callback.

$extension->on('uninstalled', function() {
    // Do something after uninstalling.
});

Extension Migrating

The migrating callback is fired after a extension is migrating. The migrating extension is passed to the callback.

$extension->on('migrating', function() {
    // Do something before migrating.
});

Extension Migrated

The migrated callback is fired after a extension is migrated. The migrated extension is passed to the callback.

$extension->on('migrated', function() {
    // Do something after migrating.
});

Form Builders

Ready

The ready callback is fired when form builder is ready and about to start the build process. The form builder is passed to the callback.

$form->on('ready', function() {
    // Ready to build
});

Built

The built callback is fired after the form builder has been built but not yet handled the request. The form builder is passed to the callback.

$form->on('built', function() {
    // Built and ready
});

Post

The post callback is fired after the form builder has been built and is about to handle the POST request. The form builder is passed to the callback.

$form->on('post', function() {
    // About to handle a post request
});

Posting

The posting callback is fired just before handling the POST request. The form builder is passed to the callback.

$form->on('posting', function() {
    // About to handle a post request
});

Posted

The posted callback is fired just after handling the POST request. The form builder is passed to the callback.

$form->on('posted', function() {
    // Post request has been made and handled
});

Validating

The validating callback is fired just before validating the form. The form builder is passed to the callback.

$form->on('validating', function() {
    // About to validate form data
});

Validated

The validated callback is fired just after validating the form. The form builder is passed to the callback.

$form->on('validated', function() {
    // Form data has been validated
});

Saving

The saving callback is fired just before saving the form entry. The form builder is passed to the callback.

$form->on('saving', function() {
    // About to save the form entry
});

Saved

The saved callback is fired just after saving the form entry. The form builder is passed to the callback.

$form->on('saved', function() {
    // Form entry has been saved
});

Make

The make callback is fired after the form builder has been built and POST request handled but before making a view response if applicable. The form builder is passed to the callback.

$form->on('make', function() {
    // About to make the form's response
});

Multiple Form Builder

Multiple form builders inherit all of the callbacks from normal standard builders.

Saving Child Form

The saving_{$slug} callback is fired just before saving the child form entry. The child form builder is passed to the callback.

$form->on('saving_example', function() {
    // About to save the "example" form.
});

Saved Child Form

The saved_{$slug} callback is fired just after saving the child form entry. The child form builder is passed to the callback.

$form->on('saved_example', function() {
    // Just saved the "example" form.
});

Versioning

The versioning callback is fired just after a child form is built that is loading a versioned entry in place of the original entry. This allows you to distribute the versioned model data to other child forms.

$form->on('versioning', function(MultipleFormBuilder $builder, VersionInterface $version) {
    $builder->setChildFormEntry(
        'entry',
        $version
            ->getModel()
            ->getAttribute('entry')
    );
});

Table Builders

Querying

The querying callback is fired at the beginning of the query process for table builders. The table builder instance and the query builder object are passed to the callback.

$table->on('querying', function(Builder $query) {
    // About to query for the table entries
});

Queried

The queried callback is fired after the query process but before returning results for table builders. The table builder instance and the query builder object are passed to the callback.

$table->on('queried', function(Builder $query) {
    // About to get entries from query builder 
});

Row Deleted

The row_deleted callback is fired after a table row has been deleted using the delete action. The table builder, model, and row entry are all passed to the callback.

$table->on('row_deleted', function(EntryInterface $entry) {
    \Log::info($entry->getId() . ' was deleted.');
});

Rows Deleted

The rows_deleted callback is fired after all table rows are deleted when using the delete action. The table builder, model, and deleted count are all passed to the callback.

$table->on('rows_deleted', function($count) {
    \Log::info($count . " records were deleted by {auth()->user()->getUsername()}.");
});

Reordered

The reordered callback is fired after table rows are reordered when using the reorder action. The table builder, model, and row count are all passed to the callback.

$table->on('reordered', function() {
    cache()->clear();
});

Tree Builders

Querying

The querying callback is fired at the beginning of the query process for tree (list) builders. The tree builder instance and the query builder object are passed to the callback.

$tree->on('querying', function(Builder $query) {
    // About to query for the table entries
});