hook_hook_info

  1. drupal
    1. drupal6
    2. drupal7 trigger.api.php
Versionen
drupal6 – drupal7 hook_hook_info()

Expose a list of triggers (events) that users can assign actions to.

Rückgabewert

A nested array:

  • The outermost array key must be the name of your module.

    • The next key represents the name of the hook that triggers the events, but for custom and contributed modules, it actually must be the name of your module.

      • The next key is the name of the operation within the hook. The array values at this level are arrays; currently, the only recognized key in that array is 'runs when', whose array value gives a translated description of the hook.

See also

hook_action_info(), which allows your module to define actions.

Note: Implementing this hook doesn't actually make any action functions run. It just lets the trigger module set up an admin page that will let a site administrator assign actions to hooks. To make this work, module needs to:

  • Detect that the event has happened
  • Figure out which actions have been associated with the event. Currently, the best way to do that is to call _trigger_get_hook_aids(), whose inputs are the name of the hook and the name of the operation, as defined in your hook_hook_info() return value)
  • Call the associated action functions using the actions_do() function.

Verwandte Themen

Code

developer-docs/hooks/core.php, line 321

<?php
function hook_hook_info() {
  return array(
    'comment' => array(
      'comment' => array(
        'insert' => array(
          'runs when' => t('After saving a new comment'),
        ),
        'update' => array(
          'runs when' => t('After saving an updated comment'),
        ),
        'delete' => array(
          'runs when' => t('After deleting a comment')
        ),
        'view' => array(
          'runs when' => t('When a comment is being viewed by an authenticated user')
        ),
      ),
    ),
  );
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen