Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
menu_link_content.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Feb 2015 at 05:29 UTC
Updated:
3 Mar 2015 at 16:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
yesct commentedoops. cloned but didn't give it a title.
titling.
Comment #2
fagoThis is already covered by #2403823: Menu link content entity validation misses form validation logic, thus marking as duplicate.
Comment #3
wim leersComment #4
wim leersReopened per #2403823-21: Menu link content entity validation misses form validation logic.
Comment #5
wim leersMenuLinkContentFormis quite confusing. It subclassesContentEntityFormbecause it's a content entity. But sinceMenuLinkContentalso is a menu link plugin,MenuLinkContentFormalso implementsMenuLinkFormInterface.And that
MenuLinkFormInterfaceimplementsPluginFormInterface, which requires the following methods:buildConfigurationForm()validateConfigurationForm()submitConfigurationForm()It's not clear to me at all when these 3 methods are called. In fact, no matter what I try, I can't get them to be called. For the simple reason that
\Drupal\Core\Menu\MenuLinkInterface::getEditRoute()ensures that we use theentity.menu_link_content.canonicalroute, which uses theMenuLinkContentFormentity form. Hence we never hit themenu_ui.link_editroute, which usesMenuLinkEditForm, which calls the given menu link plugin's form class (which is confusingly but understandably alsoMenuLinkContentForm).IOW: I believe it's safe to no longer implement
MenuLinkFormInterfacefor theMenuLinkContentmenu link plugin. If that's true, then no additional test coverage is necessary.Comment #7
pwolanin commented@Wim Leers - yes, I think we zig zagged a bit on this one, and since it probably makes sense to use the entity form, we might indeed ditch the implementation of MenuLinkFormInterface
However - the counter-argument is that it would be nice to be able to edit every menu link plugin in a standard way, so maybe we are doing it backwards currently?
Comment #8
wim leers#7: if the current way is backwards and we want to ditch subclassing
ContentEntityForm, then we'd have to reimplement a lot. I don't think that's desirable? Or do you mean something else than that?Comment #9
pwolanin commented@Wim Leers - if we'd have to reimplement a lot, then lets keep it as-is and add tests or ditch MenuLinkFormInterface?
Comment #10
wim leersThat's what #5 does! :)
Comment #11
yched commentedre @Wim #5
+ a lot, that confused me a lot as well - I opened a rename proposal in #2417799: Clarify method names in MenuLinkFormInterface
If MenuLinkContentForm doesn't need to implement MenuLinkFormInterface, that's even better :-)
Comment #12
pwolanin commentedTaking a look at this - the fails suggest something was removed that was needed in processing form values.
Comment #13
pwolanin commentedThis puts code back necessary for processing the form values.
Should possibly replace the use of the path validator here with
Url::fromUri()? Or in a separate issue?Comment #14
klausiNice cleanup, looks good. I agree with the removal of the MenuLinkFormInterface implementation. I think
Url::fromUri()is out of scope for this issue, let's just do away with the unnecessary code here. One minor nitpick then this is IMO RTBC:That indentation change is wrong.
Comment #15
tadityar commentedCorrected the indentation.
Comment #16
klausiCool, assuming the bot will come back green.
Comment #17
yched commentedYay, lots of '-' in that patch :-)
Can't we just inline extractFormValues() into buildEntity() ? No real point in splitting the logic of buildEntity in two methods, scattered apart several methods away in the class ? Would also make the method order in the class more intuitive (define form, extract values into entity, save)
Then, we should make the code use the $entity built with
parent::buildEntity()rather than$form_state->getValue(['link', 0, 'uri']- but we can also keep that for #2417783: Remove widget specific logic in MenuLinkContentForm :-pComment #18
wim leers#13 reintroduces
::extractFormValues(). But that method returns "a new definition", i.e. a new menu link definition. That doesn't make sense for a content entity form. That only makes sense for aMenuLinkFormInterfaceimplementation, which it no longer is. I think we should revert #13's interdiff, and just make it work without that. Otherwise,MenuLinkContentFormstill is very hard to comprehend.Comment #19
pwolanin commented@Wim Leers - so we need to be able to get a definition from the entity - you think this should be reworked in terms of just the entity values? it's the naming that bothers you?
Comment #20
wim leersYes, exactly, this should just use entity values. Since it doesn't implement
MenuLinkFormInterfaceanymore, none of the$definitionstuff should be necessary anymore.In other words: none of
::extractFormValues()should be necessary anymore. #13 reintroduced it, but even though I don't see yet what exactly is missing if we just omit it like #5 did, it should only be a tiny bit from::extractFormValues()that's still necessary, and then we can keep just that bit, but just do it in::buildEntity().(Basically I think #5 is what should happen, it worked fine for me, don't know why it's failing.)
EDIT: grammar fixes.
Comment #21
BassistJimmyJam commentedI'm going to work on updating the patch based on @Wim Leers comments.
Comment #22
BassistJimmyJam commentedUpdated patch to remove
::extractFormValues()and move the necessary pieces to::buildEntity().Comment #23
yesct commentedstill needs tests. adding tag.
Comment #24
BassistJimmyJam commentedMy first attempt at writing a test for Drupal, please be kind :)
Comment #27
BassistJimmyJam commentedBad commit in HEAD broke testbot. Resetting status.
Comment #28
klausiExcellent, this is almost ready!
empty line missing.
Breaks my heart to set this back to needs work for this minor nitpick, but I promise to RTBC this once you fix it :-)
Comment #29
BassistJimmyJam commentedFixed missing missing line.
Comment #30
klausiLooks good, assuming that the bot comes back green.
Comment #31
wim leersYes! So much better! :) Thanks for your awesome patch :)
Comment #32
jibranCan we add a @todo here to use helper setter methods with link to the issue?
Comment #33
alexpottre #32 that's existing code and removing the magic setters would require @todo's everywhere.
This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 45c425a and pushed to 8.0.x. Thanks!
Comment #36
alexpottIt failed retest because I committed.