1

Working on a PR to add pre and post hooks for the UFGroup entity, I looked for existing examples of entities that invoke these hooks with the 'view' $op (documented in the 'parameters' section for hook_civicrm_pre and hook_civirm_post). But I'm not finding any. This ack-grep output, for example:

$ cd /opt/buildkit/build/drupal-clean/web/sites/all/modules/civicrm
$ ack 'Hook::post\b.+\bview\b'
$ ack 'Hook::pre\b.+\bview\b'
$

Likewise, actually getting a hook implementation to fire on this op in an extension is failing for all of the entities I've tried (probably 10 or so of the more common ones like Contact, ContributionPage, etc.):

/**
 * Implements hook_civicrm_pre().
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_pre
 */
function myextension_civicrm_pre($op, $objectName, $id, &$params) {
  if ($op == 'view') {
    die('op is view');
  }
}

Can anyone name an entity in CiviCRM where this op is used in either of these hooks? If not, I'm inclined to submit a documentation patch to remove it from the docs.

Also reference: Is there a hook that will be called before each database read?

1
  • 1
    My guess is that it was based on drupal hooks, and it appears to have been patterned on hook_user, which has 'view'. But I agree it doesn't seem like it would be used anywhere because it's not a display type of hook.
    – Demerit
    Nov 25 '20 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.