1

How can I pass data to hook_entity_insert() given that the arguments it takes are fixed?

I'm writing to the database during entity save, and need to be able to pass some data in this hook.

0

Since you're not initiating the hook, you'll have to find another way. Maybe call a hook in the hook you're implementing?

If you would've been initiating the hook, you could've just passed on more parameters and used func_get_args to get the parameters, ie:

function sum ($a, $b) {
  $sum = 0;
  foreach (func_get_args() as $arg) {
    $sum += $arg;
  }
}

and call it with

sum(1, 2, 3, 4)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.