Pass data to hook_entity_insert 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.
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)