Please wait...
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
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 $tag
, callable $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
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);