It would be useful (and consistent with other hooks) to have a hook_flag_definitions_alter().

Right now, if you want to change the predefined handlers (like I was doing for one project), you will have to use hook_module_implements_alter() and unset the reference to flag_flag_definitions(), which is of course a total hack.

The implementation is pretty much a one-liner in flag_fetch_definition():

$cache = module_invoke_all('flag_definitions');
drupal_alter('flag_definitions', $cache); //new line
CommentFileSizeAuthor
#1 flag_definition_alter.patch1.08 KBquicksketch

Comments

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new1.08 KB

Hm, I'd be curious to know what sort of modification you needed that you had to alter the definition hooks. In any case, co-maintainer mooffie suggested the same thing a long while ago in #435822: Implement hook_flag_alter.

I've committed this patch which implements the combination of your suggestions and his (renaming $cache to $definitions for clarity).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ralf.strobel’s picture

Status: Closed (fixed) » Active

I'm just quickly reopening this, because I just updated to 7.x-2.0-beta6 and the changes are not in there, although the patch is supposed to be committed for a long time.

I hadn't payed attention to this for a while. Maybe it got lost along the way?

ralf.strobel’s picture

Status: Active » Closed (fixed)

I see, the problem seems to be that the dev releases are no longer available and the latest beta is still missing quite a few of the latest changes...

Reclosing, but really hoping either some new devs or an updated beta will be available soon.