Loading
Issue #3638122: Use '#config_target' in the settings forms
Summary
Uses #config_target in the settings forms of Admin Toolbar, Admin Toolbar Tools and
Admin Toolbar Search, so Drupal loads, validates and saves the settings from the
configuration schema.
Closes #3638122 (child of #3565209)
Changes
- Added
#config_targetto the form elements of the three settings forms, and removed the#default_valueproperties and the manual saving insubmitForm(). - Used core's
RedundantEditableConfigNamesTraitinstead ofgetEditableConfigNames(). - The
Menu depthselect options and the#minand#maxofmax_bundle_numbercome from theRangeconstraints of the configuration schema. - The hoverIntent timeout uses a
ConfigTargetwithtoConfigto cast the select value to an integer, as expected by the schema'sChoiceconstraint. - The labels, descriptions and other texts stay in
$this->t(), so the existing translations still apply. The only text change: thehover intentlink is now built withLinkand hasrel="noopener noreferrer". - The tools form still uses
MenuLinkRebuildManager::rebuildNow()after saving. admin_toolbar_update_8007()setssticky_behaviortoenabledif it does not exist. The setting was added without an update hook and is now required by the schema.- Updated the comments in the three configuration schemas, which said the labels and descriptions are used by the forms.
Tests
AdminToolbarSettingsFormTest: checks the saved values and their types (booleans, integers, the sticky behavior value).AdminToolbarToolsSettingsFormTest: checks a value above the maximum is rejected and the savedmax_bundle_number(integer) andshow_local_tasks(boolean) values.AdminToolbarSearchSettingsFormTest: checks the three settings are saved as booleans.- New Kernel test
AdminToolbarUpdateHooksTestforadmin_toolbar_update_8007(). - The per-file
sedline for the new test is added to the "phpstan (previous major)" CI job.
Testing
- Tested locally on Drupal 11.5: the three form Functional tests, the Kernel tests of the
three modules and
AdminToolbarToolsTest. - PHPCS and PHPStan are clean on the changed files.
#config_targetand theConfigTargettoConfigargument are available from Drupal 10.2, so they are compatible with^10.3.- Not tested yet: the Drupal 10.3 and 12.x pipelines.
Notes
Edited by David Suissa