You are here

function trigger_example_trigger_example in Examples for Developers 6

Implementation of hook_trigger_example().

Related topics

File

trigger_example/trigger_example.module, line 96

Code

function trigger_example_trigger_example($op, $count) {

  // Our module is dependent on the trigger module but other modules that this
  // code get's copied into might not so it's a good idea to check first.
  if (!module_exists('trigger')) {
    break;
  }

  // Find any the ids of any actions associated with this hook/operation pair.
  if ($aids = _trigger_get_hook_aids('trigger_example', $op)) {

    // Setup the context for our trigger.
    $context = array(
      'hook' => 'trigger_example',
      'op' => $op,
      'count' => $count,
    );

    // Since we're not operating on an object we need to create a dummy.
    $dummy = new stdClass();
    foreach ($aids as $aid => $action_info) {
      actions_do($aid, $dummy, $context);
    }
  }
}