Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-on from #2565501: Tests are not working because Dynamic page cache was committed in core.: the lazy builder callback could be moved to the flag service.
Comment | File | Size | Author |
---|---|---|---|
#9 | interdiff-7-9.txt | 1.79 KB | martin107 |
#9 | lazy_builder_service-2568129-9.patch | 5.21 KB | martin107 |
#7 | lazy_builder_service-2568129-7.patch | 5.2 KB | martin107 |
#4 | lazy_builder_service-2568129-4.patch | 5.54 KB | giancarlosotelo |
#4 | interdiff-2-4.txt | 5.51 KB | giancarlosotelo |
Comments
Comment #2
giancarlosotelo CreditAttribution: giancarlosotelo at MD Systems GmbH commentedMoving the lazy builder to a service.
Comment #3
martin107 CreditAttribution: martin107 commentedCan I suggest a better home for the function.
Looking at the FlagService methods, each operates directly on a Flag
getFlagByXYX()
getFlaggingXYX()
flag()/unflag()
and I think this new method looks a little out of place.
Would a better location for the lazyLinkBuilder() be as a method on another one of our services.
plugin.manager.flag.linktype
\Drupal\flag\ActionLinkPluginManager
I can see one minor objection ...it might look strange to have to pass in the entity manager, which we would have to do, into something advertised as a PliginManager...
Comment #4
giancarlosotelo CreditAttribution: giancarlosotelo at MD Systems GmbH commentedOk it seems a bit strange but I also think it is a better place for the lazyLinkBuilder().
Comment #5
joachim CreditAttribution: joachim commentedHmm yeah I'm not convinced of it on the plugin manager either. The plugin manager's job is pretty much just to serve up a plugin when you want one.
I also see @martin107's point that there's a tendency to use FlagService as a dumping ground for everything.
I'll have a ponder...
Comment #6
martin107 CreditAttribution: martin107 commentedGiancarlo, I apologies .. now that I look at now that I look at #4.
I think it is better that moving things into FlagService ... but it does look very out of place.
I personally am not opposed to having a service with only one method in it.
By way of making up for the bad advice .. I will do the work for the next patch .. I will try and get to this tonight.
Comment #7
martin107 CreditAttribution: martin107 commentedI have moved the function into a LazyLinkBuilder service.
Comment #8
socketwench CreditAttribution: socketwench as a volunteer commentedI'd go for a new service first, and the link plugin manager second. It's not like there isn't precedence in core for this -- CommentDefaultFormatter is a field formatter service also tasked with lazy-building.
"LazyLinkBuilder" service works as a name, although I'd prefer something a little more Flag specific and a little less task specific. "FlagLinkBuilder"?
Comment #9
martin107 CreditAttribution: martin107 commentedThanks for the nudge ... FlagLinkBuilder looks better.
Comment #10
giancarlosotelo CreditAttribution: giancarlosotelo at MD Systems GmbH commented#6 no worries I am just learning and making patches helps me a lot. So I am happy to collaborate in anyway.
Comment #11
socketwench CreditAttribution: socketwench as a volunteer commentedLooks good to go.
Comment #12
joachim CreditAttribution: joachim commentedCommitted, with the class and interface docblock summaries tweaked.