Problem/Motivation
It would be useful if FlagCountManager offered a method to count a particular flag. This would be like ::getEntityFlagCounts() except that it would also take a string flag_id param and return an integer, the count for that flag_id.
Proposed resolution
Add a new method.
Remaining tasks
Agree on the name of the method. Implement.
User interface changes
None.
API changes
Method is added.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3376688-5.patch | 1.92 KB | samitk |
Issue fork flag-3376688
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
samitk commentedI am looking into it.
Comment #3
samitk commentedHi @Liam Morland ,
I checked it and i found a similar function as you mentioned
public function getFlagEntityCount(FlagInterface $flag);Defined in the same fileFlagCountManager.The only difference is it takes
flaginstance as a argument not stringflag_id.I guess we can use getFlagEntityCount function.
Thanks
Samit K.
Comment #4
liam morland::getFlagEntityCount()gives the total number of flags not the number on a particular entity. The new method would need to take both an entity and a flag as parameters.Comment #5
samitk commentedHi Liam Morland,
Function
getFlagCountsadded, Please review.Function
getFlagCountstakes 2 arguments $flag and $entity object, $entity object is optional here.Thanks
Samit K.
Comment #6
ivnishNeeds reroll to MR. Also needs tests
Comment #8
liam morlandMerge request created with the patch in #5.
Comment #9
ivnishThanks Liam!
Could you write a simple test for it?
Comment #10
liam morlandI'm not currently working on the project that I needed this for, so I won't be able to write a test for it quickly.
Comment #11
ivnishOk, no problem
Comment #13
ivnishComment #15
deaom commentedThe tests are actually passing, the issue is with previous version of composer in the gitlab-ci template #3564269: Composer 2.9 blocks dependencies which have security advisories which makes composer previous minor fail (D 11.1). It can be ignored, so removed from the gitlab-ci this project uses or simply ignored till the issue is fixed. Up to maintainers to decide, but marking the issue as needs review as test was updated to add the new function in.
Comment #16
liam morlandThe code looks good and has tests.