Actions

Actions are a part of the Hooks system. They provide a way to running your functions at a predefined point during the execution of Saturn's systems.

You can also create custom actions that allow you to use the system to execute hooks within your plugins.

Actions don't return anything back to the action hook. To do that you'll need to use Runners.

If you're unsure which type of hook to use, please see this section, describing the difference between actions and runners.

Register an Action

To register an Action you need to use the Actions system.

Please see the below sections for examples specific to different implementations of your code.

The 'Parameters' parameter is optional.

Specification

Parameters needed

Register(string $Callback, string|array $Function, array|null $Parameters);

Parameters not needed

Register(string $ActionCode, string|array $Function);

Object-oriented functions

This will generate a new instance of the class

That means any variables defined in your class won't carry over, you should declare them globally or pass them in if you need them.

use Saturn\HookManager\Actions;

$Actions = new Actions();
$Actions->Register('ActionCode',  array(new ExampleClass(),'ExampleFunction'), array($Parameters));

Static functions

use Saturn\HookManager\Actions;

$Actions = new Actions();
$Actions->Register('ActionCode',  '\Namespace\Class::Function', array($Parameters));

Unregister an Action

You can unregister actions that you no longer need to run, this is useful if you only want to complete an action once when it may run multiple times.

Please see the below sections for examples specific to different implementations of your code.

The 'Parameters' parameter is optional.

Specification

Parameters needed

Unregister(string $ActionCode, string|array $Function);

Object-oriented functions

This will generate a new instance of the class

That means any variables defined in your class won't carry over, you should declare them globally or pass them in if you need them.

use Saturn\HookManager\Actions;

$Actions = new Actions();
$Actions->Unregister('ActionCode',  array(new ExampleClass(),'ExampleFunction'));

Static functions

use Saturn\HookManager\Actions;

$Actions = new Actions();
$Actions->Unregister('ActionCode',  '\Namespace\Class::Function');

Run an Action

You can also run actions yourself, this is useful if you're creating Custom Actions.

use Saturn\HookManager\Actions;

$Actions = new Actions();
$Actions->Run('ActionCode');

List of Action Codes

Core

ActionExecution Time

Saturn.PostStart

After Saturn starts up all core systems except router.

Saturn.End

Executes after everything else, or just before exit; is executed.

Plugin Manager

ActionExecution Time

Saturn.PluginManager.PostLoad

After Saturn has loaded all plugins.

Control Panel Plugin

If you're using the Control Panel plugin, there's loads of actions for that as well!

pageControl Panel Hooks

Custom Actions

To create a custom Action Code, you just need to enter an action name that doesn't already exist into the callback parameter.

We recommend using a prefix related to your plugin. For example: MyPlugin.ActionName. This keeps your actions distinguished from others and avoids conflicts.

Last updated