- Issue created by @malcomio
- Assigned to viren18febs
- Merge request !49Issue #3381654: Service method to get all flags for a user → (Closed) created by malcomio
- last update
about 2 years ago 46 pass - Issue was unassigned.
- Status changed to Needs review
about 2 years ago 12:08pm 17 August 2023 - 🇬🇧United Kingdom malcomio
@viren18febS thanks but I just created a merge request for this: https://git.drupalcode.org/project/flag/-/merge_requests/49
- last update
about 2 years ago 46 pass - last update
about 2 years ago 46 pass - First commit to issue fork.
- 🇨🇦Canada joelpittet Vancouver
Thanks I just caught up the code, it was failing on some cleaned up namespace use statements. We are using this and it's very helpful, thank you @malcomio. I manually reviewed the code, and the abstraction is nice clean-up for the unflagAllByUser()
- ivnish Kazakhstan
- 🇨🇦Canada joelpittet Vancouver
Looks like the issues were corrected, thanks Ramil g. The remaining are unrelated phpstan for other tests, not appropriate to fix here.
- Status changed to RTBC
5 months ago 8:45am 29 March 2025 - Status changed to Closed: duplicate
4 days ago 12:38pm 19 August 2025 - ivnish Kazakhstan
Sorry, already fixed here ✨ add a service method to get all of a user's flagged entities for a given flag Active . Credits will be added
- 🇨🇦Canada joelpittet Vancouver
@ivnish, I think this one’s actually a different use case, so reopening as RTBC 🙂
The diff:getFlagUserFlaggings($flag, $user)
: Only returns the user’s flaggings for a specific flag.getAllFlaggingByUser(?$account, $flag = NULL, $session_id = NULL)
: Returns all flaggings for a user, with extra handling for anonymous users via session ID.
Since
getFlagUserFlaggings()
already covers the per-flag case, maybe we could simplifygetAllFlaggingByUser()
to just handle “all by user” and drop the “optionally narrowed by flag” bit? That way each method has a clear, distinct role.Looks like you’re targeting 5.x, so I’ve moved it over there.
- 🇨🇦Canada joelpittet Vancouver
joelpittet → changed the visibility of the branch 5.x to hidden.
- ivnish Kazakhstan
so reopening as RTBC
Ah, sorry)
Since getFlagUserFlaggings() already covers the per-flag case, maybe we could simplify getAllFlaggingByUser() to just handle “all by user” and drop the “optionally narrowed by flag” bit? That way each method has a clear, distinct role.
Could you update the MR ?
- Merge request !156Issue #3381654: Service method to get all flags for a user → (Merged) created by joelpittet
- 🇨🇦Canada joelpittet Vancouver
@ivnish woah, you’re quick! I was juggling branches since I couldn’t retarget the MR to 5.x, so I created a new one and moved the code over.
Totally up to you, but my thought is to keep the signature specific to “all flags for user,” so the distinction between the two methods stays clear.
- 🇨🇦Canada joelpittet Vancouver
Thanks for retargetting the code in MR 49 to 5.x branch. I will put my proposal in MR 156 since they are now both on 5.x
- 🇨🇦Canada joelpittet Vancouver
I added
populateFlaggerDefaults()
because I think we were missing that, and removed the $flag because that use-case is covered by the other issue. Moving to Needs Review, maybe you can have a look @ivnish? - ivnish Kazakhstan
LGTM
if no more code updates are planned, I think I can commit this
- 🇨🇦Canada joelpittet Vancouver
@ivnish I am good with committing this as-is. We could test session too but there are probably other tests already checking for that condition as we copied from other service methods. So 🚀
-
ivnish →
committed 91f0af0a on 5.x authored by
joelpittet →
Issue #3381654: Service method to get all flags for a user
-
ivnish →
committed 91f0af0a on 5.x authored by
joelpittet →
- 🇨🇦Canada joelpittet Vancouver
Awesome, thanks for giving the feature a second thought!