Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
joachim CreditAttribution: joachim commentedComment #2
joachim CreditAttribution: joachim commentedA number of the hooks that the above summary says are no longer present are nonetheless still documented in the api.php file, no?
Comment #3
socketwench CreditAttribution: socketwench commentedProbably. We should go nuke them in a separate issue.
Comment #4
joachim CreditAttribution: joachim commentedUpping 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....
Comment #5
joachim CreditAttribution: joachim commentedComment #6
socketwench CreditAttribution: socketwench as a volunteer commentedUpdated reset event hook.
Comment #7
joachim CreditAttribution: joachim commentedComment #8
joachim CreditAttribution: joachim commentedUpdated reset event, delete hooks, access hooks.
Comment #9
socketwench CreditAttribution: socketwench as a volunteer commentedComment #10
socketwench CreditAttribution: socketwench as a volunteer commentedComment #11
socketwench CreditAttribution: socketwench as a volunteer commentedComment #12
socketwench CreditAttribution: socketwench as a volunteer commentedComment #13
joachim CreditAttribution: joachim commentedComment #14
martin107 CreditAttribution: martin107 as a volunteer commentedAdded hook_token to the table.
#2500091: Re-implement hook_tokens()
Comment #15
joachim CreditAttribution: joachim commentedhook_token() is not one of our hooks though -- this issue is about the hooks that Flag module invents, not the hooks that Flag implements.
Comment #16
martin107 CreditAttribution: martin107 as a volunteer commentedI 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?
Comment #17
joachim CreditAttribution: joachim commented> 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.