I'm writing a module that should use hook_votingapi_storage_add_vote to run certain actions.
The problem is that the module (that is enabled and other hooks work) doesn't use the hook, here is the declaration:
/**
* Implements of hook_votingapi_storage_add_vote().
*/
function edem_notifiche_votingapi_storage_add_vote(&$vote) {
// Variable to get breakpoint
$a = 1;
}
My module (edem_notifiche) works, my debugger works too and also other hooks on the same module.
What's wrong?
Thanks.
Comments
Comment #1
torotil commentedhook_votingapi_storage*()are not hooks in the classical sense. Since there can be only one active implementation at a time there is a variable calledvotingapi_storage_modulethat indicates the module that handles the votingapi_storage.In other words use
variable_set('votingapi_storage_module', 'edem_notifiche');or$conf['votingapi_storage_module'] = 'edem_notifiche';and you should be fine.Comment #2
arrubiu commentedMh ok, as soon as possible I'll try it.
Two questions:
- is the function declaration right?
- does the function replace the "original" function or is a hook that performs his actions after the original function?
thanks
Comment #3
torotil commentedIt replaces the original function. The declaration looks good.
Comment #4
arrubiu commentedIt doesn't work.
On my module I've:
And this is the variable:
But I've a blank page and apache says:
[Mon Apr 08 08:54:46 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function edem_notifiche_votingapi_storage_select_votes() in /home/sdurzu/workspace/subversion/e-dem/trunk/code/sites/all/modules/contrib/votingapi/votingapi.module on line 363Have I to replace EVERY function declared in the votingapi.api.php^
Comment #5
torotil commentedExactly. The storage module needs to take care of ALL storage functions.
Comment #6
arrubiu commentedMhh, I'll try Rules integration, if it works.
Let me say that this use of hooks is a bit ambiguos, compared with the default implementation of hooks and maybe it should be explained in a better way.
If Rules's integration doesn't work I'll try to redeclare every function.
Thanks!
Comment #7
torotil commentedYeah. In 3.x The storage will be an class so you can inherit the default implementation. Sorry for the complications I've inherited that architecture (I've only been maintainer since last autumn).
In the meanwhile you could also add dummy/proxy functions in your module so you don't need to c&p the default implementation.
Comment #8
arrubiu commentedHowever the Rules - VotingAPI module (http://drupal.org/project/voting_rules) seems works.
Comment #10
shailu29 commenteddocumentation here: https://drupal.org/node/68877) is correctly triggered.