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.
The way the config overrides work is a module can provide an optional config file that defines keys the submodule should override. For example, this is one for the smtp module:
# smtp/config/optional/key_config.key_override.smtp.yml
id: smtp
module: smtp
config_objects:
- name: smtp.settings
paths:
- key: smtp_password
label: SMTP Password
The idea for having this functionality as a submodule of key as opposed to a separate project is to lower the friction for adoption by not requiring invasive patching on the part of module maintainers.
Comment | File | Size | Author |
---|---|---|---|
#17 | 2771013-17.patch | 15.94 KB | tynor |
#13 | interdiff.patch | 1.9 KB | tynor |
#13 | 2771013-13.patch | 15.97 KB | tynor |
#11 | 2771013-11.patch | 16 KB | tynor |
#9 | 2771013-9.patch | 15.94 KB | tynor |
|
Comments
Comment #2
tynor CreditAttribution: tynor commentedComment #3
tynor CreditAttribution: tynor commentedComment #4
tynor CreditAttribution: tynor commentedAfter discussion with Rick, here are is an updated patch with an interdiff using the \NestedArray::getValue() function rather than manual array element extraction, as well as styling updates.
Comment #5
tynor CreditAttribution: tynor commentedFixed an issue with the previous patch that tried to inject a config.installer into KeyConfigForms when none is taken.
Comment #7
rlhawkTynor, the last patch appears to be corrupt. Can you fix it and repost?
Comment #8
tynor CreditAttribution: tynor commentedHere's the fresh patch.
Comment #9
tynor CreditAttribution: tynor commentedActually, ignore that last one, I accidentally didn't include some changes (targeted the wrong revision for the diff.)
Comment #10
tynor CreditAttribution: tynor commentedWorking on refactor into centralized override management, removing need for a global form_alter.
Comment #11
tynor CreditAttribution: tynor commentedHere is a patch implementing the centralized override management.
I'm not sure what text should appear on the Overrides form, but the functionality is working quite nicely.
Comment #12
tynor CreditAttribution: tynor commentedComment #13
tynor CreditAttribution: tynor commentedCouple small updates from Chris on the layout of the Overrides page. There is also now a container stub for putting text.
Comment #14
tynor CreditAttribution: tynor commentedUpdated example config file to remove the now unnecessary label.
Comment #15
rlhawkREADME.md still has the config object label in the example code, so we should remove it there also.
Comment #16
rlhawkThis generally looks good. In my tests, though, the actual key value is not getting copied over to the key configuration when importing.
Comment #17
tynor CreditAttribution: tynor commentedFixed the README.md (new diff attached.)
I tried to reproduce the error with importing, but it looks like it's working correctly for me. Can you try again and just make sure it's the most recent patch?
Here are the steps I took:
composer require --update-no-dev drupal/key
composer require --update-no-dev drupal/smtp
smtp/config/optional/key_config.key_override.smtp.yml
admin/config/system/keys/overrides
drush ev "echo Drupal::configFactory()->getEditable('smtp.settings')->get('smtp_password'), PHP_EOL"
drush ev "echo Drupal::configFactory()->get('smtp.settings')->get('smtp_password'), PHP_EOL"
Comment #18
rlhawkComment #19
rlhawkThis functionality has been added directly to the Key module, rather than as a submodule.
Comment #20
rlhawk