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.
Part of #1696224: Remove system_settings_form()
menu_configure uses system_settings_form() and needs to use system_config_form().
Comments
Comment #1
nick_schuch CreditAttribution: nick_schuch commentedFirst attempt at this patch.
Comment #3
adamdicarlo CreditAttribution: adamdicarlo commentedThis likely still needs work, but should get us closer:
Comment #4
adamdicarlo CreditAttribution: adamdicarlo commentedComment #6
sunThe new configuration system does not support default values anymore.
When a default value behavior is desired, you need to get the value of the key, and if that returns no value, then override it with the desired default value.
E.g., in this case:
The configuration object name should be 'menu.settings'
Let's clean up these keys to make the config object more self-explanatory and leverage sub-keys for doing so. For example:
1) active_menus was default_active_menus. The actual YAML syntax for an empty array needs to be double-checked.
2) On override_parent_selector: Please note that, as of now, all configuration values are always strings; so a Boolean false would not be supported.
When assigning the config object to a variable way out of context like this (which is fine), then we need to use a self-descriptive variable name; e.g., $menu_config.
There's no need to check for the existing values. Let's use the standard pattern here - just simply:
1) It looks like this code did not exist before -- are we sure that it is required, given that menu_set_active_menu_names() computes the default value automatically already?
2) In any case, the config object cannot be saved this way, since you're re-instantiating a completely new object in the second line.
ok, this is going to be tricky. :-/
Comment #7
nick_schuch CreditAttribution: nick_schuch commentedSecond attempt. I have tried to take on all the advice in comment #6. Let me know what you think.
Comment #8
nick_schuch CreditAttribution: nick_schuch commentedComment #10
tobiasbThe patch converts only the menu settings. other menu stuff should be converted, when we have a solution for #1175054: Add a storage (API) for persistent non-configuration state.
Comment #11
sunTagging.
Comment #12
aspilicious CreditAttribution: aspilicious commentedThere are better ways to check if a module is enabled
Maybe this code is better?
-29 days to next Drupal core point release.
Comment #13
tobiasbyes looks better so.
Comment #14
sunLet's remove this -- functional code should not refer to tests. :)
I guess the second line intends to get the source.secondary_links key instead of the same for main links?
If these two are really the only settings of Menu module, then I wonder whether the additional 'source' parent key makes sense?
Let's not change the $form array keys for now, please.
Missing "_update_" in "menu_update_8000" :)
Missing trailing comma for last array element.
Comment #15
tobiasbFixed all mistakes ;-)
Comment #16
sun&$form_state is still not taken by reference though :)
1) Sets the old/previous config keys.
2) Looks up the old/previous keys in the submitted form values (they equal the keys in the $form array).
3) Chained method calls on an object should be indented with two spaces.
Ditto on config keys.
Comment #17
tobiasbOk fixed this also and a typo module_exist -> module_exists
Comment #18
aspilicious CreditAttribution: aspilicious commentedremove "source."
same
-30 days to next Drupal core point release.
Comment #19
tobiasbfixed also that ;-)
Comment #20
sunThanks! This looks ready to fly for me.
Comment #21
alexpottCouple of minor nitpicks...
PHPDoc block needs:
@ingroup forms
@see menu_configure_submit()
Unnecessary @see in PHPDoc block... the function description covers this.
Comment #22
dagmarAdded suggestions from #21.
Comment #24
dagmar#19: 1697170-19-convert-menu_configure-to-new-configuration.patch queued for re-testing.
Comment #25
dagmar#22: 1697170-22-convert-menu_configure-to-new-configuration.patch queued for re-testing.
Comment #26
alexpottThis is good to go. Thanks everyone for the good work!
Comment #27
Dries CreditAttribution: Dries commentedCommitted to 8.x. Nicely done. Thanks all.