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

发布于 2024-10-19 13:05:59 字数 945 浏览 1 评论 0原文

我正在编写一个 Drupal 模块(filemaker)并定义了一些自定义触发器。触发器显示得很好,但显示“此触发器没有可用的操作”。在管理/构建/触发器/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);
[...]

I am writing a Drupal module (filemaker) and defined some custom triggers. The triggers show up just fine, but say 'No available actions for this trigger.' at admin/build/trigger/filemaker.

Any idea how to make actions available for my trigger?

Thanks in advance.

/**
 * 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);
[...]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

口干舌燥 2024-10-26 13:05:59

知道了。在此处找到了答案。

需要一个 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');
      }
    }
  }
}

Got it. Found the answer here.

Needed a 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');
      }
    }
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文