Problem/Motivation

FlagServiceInterface::getFlaggings() may take a large variation of parameters. While this works, it is seen as bad DX and requires a nuanced understanding of the method operation.

Proposed resolution

Define additional methods that accept a required number of parameters. These new methods may rely on getFlaggings(), or perform their own entity queries. In the latter case, getFlaggings() should be removed.

Remaining tasks

Create patch.

User interface changes

None.

API changes

Additional flag service methods for retrieving flaggings would be available. FlagServiceInterface::getFlaggings() may no longer be available.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

socketwench created an issue. See original summary.

socketwench’s picture

Removed FlagService::getFlaggings() and FlagService::unflagAll() and replaced them with several methods.

martin107’s picture

Assigned: Unassigned » martin107

I think this moves us in a positive direction. so +1 from me.

All the changes look good with one minor quibble.

My idiot brain did a "What the what now!" and went running for the documentation...when coming across the method name unflagAllFlag

I suggest renaming it to FlagService::unflagAllByFlag($flag)

I am out of time tonight - I am posting early because naming things is hard and others are welcome to take a different perspective.

I will post a patch tomorrow.

socketwench’s picture

Status: Needs review » Needs work

The last submitted patch, 4: flippyFloppy_2747833.4.patch, failed testing.

The last submitted patch, 4: flippyFloppy_2747833.4.patch, failed testing.

martin107’s picture

Thanks for doing that,

socketwench++

The test failing from an unrelated flag patch look similar.

https://www.drupal.org/node/2755683#comment-11346979

socketwench’s picture

Retesting, it looks like the branch errors bit us.

martin107’s picture

Assigned: martin107 » Unassigned
Status: Needs work » Reviewed & tested by the community

I think this is good to go.

Patch looks good.

I have seen unease expressed by others in separate issues about how digging through over complex methods leaves a bad smell.

There is a lot of care and thought here, to make the DX cleaner. and to my mind answer all the questions.

sockerwench++

socketwench’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed
FileSize
1.11 MB

This is one of those patches that I wrote, I don't like, but others think it's improvement... So...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.