Problem/Motivation

8.x is a complete rewrite of Flag. Many of the key API hooks have been replaced with new mechanisms.

Proposed resolution

Track the changes in an issue while the rewrite process is ongoing, and close this issue after developer documentation for 8.x has been written.

Remaining tasks

  • Determine if the remaining hooks need to be implemented, and if so, what API mechanism would best provide the functionality.
  • Create documentation pages for developers.
  • Write Change Records for removed / changed hooks

User interface changes

N/A.

API changes

Many, see below.

Hook Name Flag 8.x equivalent
hook_flag_type_info Replaced with the @FlagType plugin.
hook_flag_type_info_alter Still exists, using plugin manager.
hook_flag_default_flags Replaced with CMI.
hook_flag_default_flags_alter Replaced with core hook hook_ENTITY_TYPE_load().
hook_flag_alter Replaced with core hook hook_ENTITY_TYPE_load().
hook_flag_options_alter Not implemented. A custom flag type plugin may be defined.
hook_flag_flag Replaced with entity flagged event.
hook_flag_unflag Replaced with entity unflagged event.
hook_flag_validate Removed: See #2744307: Implement or remove hook_flag_validate()
hook_flag_access Removed. To be replaced with something else: see #2584647: Flagging access system not extensible.
hook_flag_access_multiple Removed. To be replaced with something else: see #2584647: Flagging access system not extensible.
hook_flag_link_type_info Replaced with @ActionLink plugin
hook_flag_link_type_info_alter Still exists, using plugin manager.
hook_flag_link Replaced with @ActionLink plugin
hook_flag_delete Still exists, as core hook_ENTITY_TYPE_delete().
hook_flag_reset Resets proved problematic for scaling. Instead, ENTITY_UNFLAGGED may now handle multiple flaggings.
hook_flag_javascript_info_alter Removed: #2744295: Delete hook_flag_javascript_info_alter()
hook_flag_export_alter Not present. Import export functionality replaced by CMI.

Comments

joachim’s picture

Issue summary: View changes
joachim’s picture

A number of the hooks that the above summary says are no longer present are nonetheless still documented in the api.php file, no?

socketwench’s picture

Probably. We should go nuke them in a separate issue.

joachim’s picture

Category: Task » Bug report
Priority: Normal » Major

Upping this so we know it's a release blocker.

I spotted hook_flag_alter() today while working on something else. Presumably its functionality can be taken care of by the core hook https://api.drupal.org/api/drupal/core!modules!system!entity.api.php/fun....

joachim’s picture

Issue summary: View changes
socketwench’s picture

Issue summary: View changes

Updated reset event hook.

joachim’s picture

Issue summary: View changes
joachim’s picture

Category: Bug report » Plan
Issue summary: View changes

Updated reset event, delete hooks, access hooks.

socketwench’s picture

Issue summary: View changes
socketwench’s picture

Issue summary: View changes
socketwench’s picture

Issue summary: View changes
socketwench’s picture

Issue summary: View changes
joachim’s picture

Issue tags: +beta blocker
martin107’s picture

Issue summary: View changes

Added hook_token to the table.

#2500091: Re-implement hook_tokens()

joachim’s picture

Issue summary: View changes

hook_token() is not one of our hooks though -- this issue is about the hooks that Flag module invents, not the hooks that Flag implements.

martin107’s picture

not the hooks that Flag implements.

I can't answer this question with any certainty because it is not a facet of this module I use

but what is the upgrade strategy for someone waiting for the code in flag_tokens.inc's flag_tokens() function to become uncommented.... if there is a better alternate solution then my want is open an issue to simply removed the dead code.

Maybe your line that this is something that can wait until after the beta blockers are complete?

joachim’s picture

> but what is the upgrade strategy for someone waiting for the code in flag_tokens.inc's flag_tokens() function to become uncommented.... if there is a better alternate solution then my want is open an issue to simply removed the dead code.

That's not this issue's concern.

This issue is about the hooks *provided* by Flag, not *implemented* by Flag. All the hooks in the table are called hook_flag_foo(). It's the hooks that developers would have implemented in their own code to customize Flag.