At the moment, we have lots of methods on the Flag entity that are in pairs, like:

- getFlagLongText()
- getUnflagLongText()

This doesn't seem like good DX to me, because code using these always has to something like this:

    $title = $action === 'unflag' ? $flag->getUnflagShortText() : $flag->getFlagShortText();

This is unwieldy.

It would be nicer to be able to do:

    $title = $flag->getShortText($action);

and let the internals return the right one of the flag/unflag variants.

Comments

joachim created an issue. See original summary.

martin107’s picture

Status: Active » Needs review
StatusFileSize
new5 KB

I think this is good idea.

Status: Needs review » Needs work

The last submitted patch, 2: refactor-2868098-2.patch, failed testing.

martin107’s picture

I will fix this up soon.

martin107’s picture

Assigned: Unassigned » martin107
martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new24.46 KB
new19.46 KB

In the next iteration ... I have fixed up testing and the forms.

Status: Needs review » Needs work

The last submitted patch, 6: FormsAndTests-2868098-6.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new24.46 KB
new609 bytes

Butter fingers!

Status: Needs review » Needs work

The last submitted patch, 8: slippy-2868098-8.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new28.65 KB
new8.52 KB

Oh rats I missed conversion of

getUnflagShortText()

martin107’s picture

Assigned: martin107 » Unassigned
joachim’s picture

Thanks for working on this. I didn't realize there were so many calls -- hope you used find & replace! :)

Here's a new patch:

- couple of whitespace nitpicks
- changed the form to use the plain get() method, which I think makes it easier to read as it's the same property name as the form element. The form is tied to the innards of the FlagType class anyway in the names of the form elements, so hiding internals here isn't really relevant.
- also handled the flag message methods. (And in doing discovered a WTF: #2870279: [meta] [regression] Flag message is not used anywhere)

martin107’s picture

changed the form to use the plain get() method,

That is a good idea... it was something that was making me feel grumpy about my own solution.

In terms of review I have had a slow visual scan of the patch .. everything looks in order / better.

so +1 from me.

joachim’s picture

Status: Needs review » Fixed

Good enough for me -- we have too many patches needing review and they're holding up further work, so I'm going to say let's go with this.

  • joachim committed 82624ed on 8.x-4.x authored by martin107
    Issue #2868098 by martin107, joachim: Changed all methods for getting...

Status: Fixed » Closed (fixed)

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