Inconsistent FlaggingEvent and UnflaggingEvent parameters make hard to reuse same code to handl

Created on 25 June 2016, over 8 years ago
Updated 19 February 2025, 18 days ago

Problem/Motivation

As a module developer that wants to take advantage of flag module and implement my own logic of some updates based on flagged/unflagged content, I'd like to subscribe to both events at the same time, and I have no problems with that, but every time one will subscribe to both events, they will have to handle events differently in their code, as the API is inconsistent, FlaggingEvent works with one flagging, while UnflaggingEvent works with an array of flaggings.

Proposed resolution

Drupal core content entities use foreach to iterate over entities in postDelete and send hook_entity_delete separately for every one, I'm wondering if it would be better for DX to do the same for UnflaggingEvent.

Remaining tasks

Provide a patch

User interface changes

None

API changes

UnflaggingEvent constructor accepts array of flaggings entities, after the change it should accept one flagging.

Data model changes

None

πŸ“Œ Task
Status

Closed: outdated

Version

4.0

Component

Flag core

Created by

πŸ‡ΊπŸ‡ΈUnited States asgorobets

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024