我的自定义Drupal触发器没有可用的操作

时间:2011-02-27 02:47:52

标签: drupal drupal-6 drupal-modules

我正在编写一个Drupal模块(filemaker)并定义了一些自定义触发器。触发器显示得很好,但是说“没有针对此触发器的可用操作”。在admin / build / trigger / filemaker。

知道如何为我的触发器提供操作吗?

提前致谢。

/**
 * Implementation of hook_hook_info().
 */
function filemaker_hook_info() {
  return array(
    'filemaker' => array(
      'filemaker' => array(
        'create' => array(
          'runs when' => t('After creating a FileMaker record'),
        ),
        'update' => array(
          'runs when' => t('After updating a FileMaker record'),
        ),
      ),
    ),
  );
}

/**
 * Implementation of hook_filemaker().
 */
function filemaker_filemaker($op, $node) {
  $aids = _trigger_get_hook_aids('filemaker', $op);
  $context = array(
    'hook' => 'filemaker',
    'op' => $op,
    'node' => $node,
  );
  actions_do(array_keys($aids), $node, $context);
}

[...]
    // Fire off the hook.
    module_invoke_all('filemaker', 'create', $node);
[...]

1 个答案:

答案 0 :(得分:0)

知道了。找到了答案here

需要一个hook_action_info_alter()。

/**
 * Implementation of hook_action_info_alter().
 */
function filemaker_action_info_alter(&$info) {

  // Loop through each action.
  foreach ($info as $type => $data) {

    // Only add our trigger to node or system actions.
    if (stripos($type, "node_") === 0 || stripos($type, "system_") === 0) {

      // Don't remove any triggers that are already added to the approved list.
      if (isset($info[$type]['hooks']['application'])) {
        $info[$type]['hooks']['filemaker'] = array_merge($info[$type]['hooks']['filemaker'], array('create', 'update'));
      }

      // Add our trigger to the approved list of hooks.
      else {
        $info[$type]['hooks']['filemaker'] = array('create', 'update');
      }
    }
  }
}