CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Suggestion: Add an "invokehook" hook that is called every time a hook is called
Pages: [1]

Author Topic: Suggestion: Add an "invokehook" hook that is called every time a hook is called  (Read 1533 times)

NatHolder

  • Guest
Suggestion: Add an "invokehook" hook that is called every time a hook is called
March 24, 2009, 12:24:56 pm
This is just a suggestion to add a call to a module hook function that would be called every time a hook is called.  The new hook could look like this:

Code: [Select]
/**
 * This hook is called before every hook function is called.  Useful to trap everything, to see which
 * hooks are called when.  Also for any general functionality across all hooks (like saving globals
 * perhaps?)
 *
 * @param string $fnName      hook function name being invoked
 * @param mixed $arg1         argument number 1 passed to the hook function
 * @param mixed $arg2         argument number 2 passed to the hook function
 * @param mixed $arg3         argument number 3 passed to the hook function
 * @param mixed $arg4         argument number 4 passed to the hook function
 * @param mixed $arg5         argument number 5 passed to the hook function
 */                 
function nafyhooks_civicrm_invokehook ( $fnName, $arg1, $arg2, $arg3, $arg4, $arg5 ) {
trigger_error("nafyhooks_civicrm_invokehook called for fnName $fnName");
}

I've modified the file civicrm/CRM/Utils/Hook/Drupal.php to implement this in my Drupal CiviCRM deployment (inserted after line 45):
Code: [Select]
                $fnInvokeHookName = "{$module}_civicrm_invokehook";
                if ( function_exists( $fnInvokeHookName ) ) {
                    $fnInvokeHookName( $fnName, $arg1, $arg2, $arg3, $arg4, $arg5 );
                }
« Last Edit: March 24, 2009, 12:29:36 pm by Nat Holder »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Suggestion: Add an "invokehook" hook that is called every time a hook is called
March 24, 2009, 03:09:12 pm

nat:

other than adding a debug statement and tracing the hook calls, what purpose would this hook solve?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

NatHolder

  • Guest
Re: Suggestion: Add an "invokehook" hook that is called every time a hook is cal
March 24, 2009, 04:33:16 pm
Quote from: Donald Lobo on March 24, 2009, 03:09:12 pm
other than adding a debug statement and tracing the hook calls, what purpose would this hook solve?
none that i can think of.  Just wanted to put it out there in case someone thinks of something.

~nat

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Suggestion: Add an "invokehook" hook that is called every time a hook is called

This forum was archived on 2017-11-26.