I have created two actions in code, one simple and one advanced.
function userbeep_action_info() {
return array(
'userbeep_beep_action' => array(
'type' => 'system',
'label' => t('Beep annoyingly'),
'configurable' => FALSE,
'triggers' => array('node_view', 'node_insert', 'node_update', 'node_delete')
),
'userbeep_multiple_beep_action' => array(
'type' => 'system',
'label' => t('Beep multiple times'),
'configurable' => TRUE,
'triggers' => array('node_view', 'node_insert', 'node_update', 'node_delete')
)
);
}
Now the simple action (i.e. the non-configurable one) will appear in my Triggers menu automatically, but I need to create the advanced one in admin/config/system/actions before I can use it.
What I’d like to do is have my module automatically create the advanced action. There are two ways I can see this working:
1) Add something to an .install file to install and uninstall upon loading the module.
2) Package these settings using Features
Ideally, I’d like to do this programmatically using 1), but I’m also keen to learn about Features. I installed the module but saw no obvious way to do this.
Moving forwards, would there also be a way to package / set up the Trigger using these actions so that the user doesn’t have to set this up manually?
1) You can use the Actions API methods –
actions_saveandactions_deletefor this. (See includes/actions.inc).hook_install(),
hook_uninstall(),
2) Does Features support exporting actions? For packaging non-configurable actions,
hook_action_info()is good enough, I feel.3) Again, using code, you can explicitly assign actions to triggers by adding entries to the
trigger_assignmentstable as shown below: