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.
Problem/Motivation
If our goal is to segregate our interfaces by workflow types that are configurable and workflows that are not, I think it makes sense to move the methods for transition/state forms to WorkflowTypeFormInterface/WorkflowTypeFormBase.
That leaves implementations of workflow types that are simple and don't require the collection of extra information for states/transitions/as a whole light.
Proposed resolution
Move these methods.
Remaining tasks
Discuss and agree on an approach.
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#9 | 2877926-9.patch | 11.64 KB | Sam152 |
#9 | interdiff.txt | 4 KB | Sam152 |
#7 | 2877926-7.patch | 11.82 KB | timmillwood |
#7 | interdiff-2877926-7.txt | 3.64 KB | timmillwood |
Comments
Comment #2
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedLets see what tests break.
Comment #4
timmillwoodNot sure I fully understand why we need this level of abstraction, but fixing the test anyway.
@Sam152 - I'll ping you on IRC so you can convince me.
Comment #5
timmillwoodHere's a better fix for the issue, thus allowing TestType workflow plugin to stay as only extending WorkflowTypeBase and not WorkflowTypeFormBase. Then use ComplexTestType to extend WorkflowTypeFormBase and test that functionality.
Comment #6
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedMaybe we should extract getTypePlugin into a variable in all the cases here.
Otherwise, I like it!
Comment #7
timmillwoodDeal!
Here's a
$workflow_type_plugin
for you.Comment #8
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commented+1 RTBC, but probably should have someone else review this based on #2.
Comment #9
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedMinor OCD, we already have 7 instances of $workflow_type, none of $workflow_type_plugin + updating the formatting to be on one line.
Comment #10
timmillwoodIn #8 @Sam152 RTBC'd my code, I RTBC his code, so we're all good?
Comment #11
larowlanthis breaks duck-typing - instanceof always feels like an anti-pattern to me - can you elaborate more as to why we want to do this?
this looks unused?
Comment #12
larowlanUpdating status
Comment #13
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedRe: #11.2, the idea here is not forcing plugins to implement WorkflowTypeFormInterface, with empty implementations where forms aren't required. We're already checking the type of plugin the workflow type is to ensure \Drupal\Core\Plugin\PluginFormInterface::buildConfigurationForm is optional, this issue is just giving state and transition forms the same treatment.
A similar concept exists with ImageEffectBase and ConfigurableImageEffectBase. I guess the trade off here is, do we want plugins implementing methods that are potentially irrelevant or segregate the interfaces accordingly and check those types where relevant.
Comment #14
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedDiscussed this with @larowlan. It was suggested to add a method on the base called hasForms or something like that. Having thought about this, I'm in two minds about this.
One one hand it makes the code a bit cleaner, instanceof checks are generally associated with anti-patterns so it's nice to move that decision somewhere else. On the other hand, it doesn't actually enforce at a language level that the set of methods we need from the interface are actually going to be implemented. A plugin implementation could technically return TRUE from the method, while not implementing the interface. Maybe a sign that a convention over a language feature is a smell. It also adds a method to the "simple" workflow implementation that doesn't really make sense in isolation. Why does a "hasForms" method exist in a context where I never expected a form in the first place?
Maybe a final method on the base which checks static::class implements the right interface would alleviate the first issue for me, but it's a coin toss for me. I probably lean towards simply using instanceof checks where appropriate and deferring to the pattern we already have.
NW for consensus.
Comment #15
timmillwoodI'm a big
instanceof
fan, and didn't realise it was anti-pattern. I'd much rather than do that than add a method, which basically does the same.I still have no issue with #9 (apart from the unused use).
Comment #16
timmillwoodMoving this back to Needs Review, because I think review is what is needed base in #14, not work.
Comment #17
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI think we're going to need this even more once #2896722: Leverage PluginWithFormsInterface to encapsulate @WorkflowType schema and clean up state/transition form methods. is done.
Comment #18
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #19
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #20
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedClosing in favour of the new approach outlined in #2896722: Leverage PluginWithFormsInterface to encapsulate @WorkflowType schema and clean up state/transition form methods.
Comment #21
xjm