Actions

Actions are one of the two types of Hooks.

They provide a way for running a function at a specific point in the execution of Mailwizz Core and extensions. They are the counterpart to Filters.

You can find a detailed list with description and location inside the project here.

Add Action Add Action

The process of adding an action includes two steps.

First, you need to create a Callback function which will be called when the action is run. Second, you need to add your Callback function to a hook which will perform the calling of the function.

You will use the addAction() function, passing at least two parameters, string $tagcallable $callback.

Yii::app()->hooks->addAction('console_command_daily', array($this, '_runBackup'), 1000);

This will add an action called ‘console_command_daily’, that will execute the method ‘_runBackup‘ of the class where the action was added.

Do Action Do Action

To trigger an action use the doAction($tag, $arg = null), where $tag is the action name and $arg possible arguments to that will be used by the callback.

For the above added action, the following code will trigger the callback execution:

Yii::app()->hooks->doAction('console_command_daily', $this);

Was this article helpful?

Related Articles