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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tynor created an issue. See original summary.

tynor’s picture

tynor’s picture

Status: Active » Needs review
tynor’s picture

After 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.

tynor’s picture

Fixed an issue with the previous patch that tried to inject a config.installer into KeyConfigForms when none is taken.

The last submitted patch, 5: 2771013-5.patch, failed testing.

rlhawk’s picture

Tynor, the last patch appears to be corrupt. Can you fix it and repost?

tynor’s picture

Here's the fresh patch.

tynor’s picture

Actually, ignore that last one, I accidentally didn't include some changes (targeted the wrong revision for the diff.)

tynor’s picture

Status: Needs review » Active

Working on refactor into centralized override management, removing need for a global form_alter.

tynor’s picture

FileSize
16 KB

Here 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.

tynor’s picture

Issue summary: View changes
tynor’s picture

FileSize
15.97 KB
1.9 KB

Couple small updates from Chris on the layout of the Overrides page. There is also now a container stub for putting text.

tynor’s picture

Issue summary: View changes

Updated example config file to remove the now unnecessary label.

rlhawk’s picture

README.md still has the config object label in the example code, so we should remove it there also.

rlhawk’s picture

This generally looks good. In my tests, though, the actual key value is not getting copied over to the key configuration when importing.

tynor’s picture

FileSize
15.94 KB

Fixed 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:

  1. Install standard Drupal 8 site
  2. Install key with composer require --update-no-dev drupal/key
  3. Install smtp with composer require --update-no-dev drupal/smtp
  4. Create the smtp override config file in smtp/config/optional/key_config.key_override.smtp.yml
  5. Apply the patch
  6. Set the smtp password
  7. Go to admin/config/system/keys/overrides
  8. Click on "Import"
  9. Verify that the smtp_password setting was set to the key id with drush ev "echo Drupal::configFactory()->getEditable('smtp.settings')->get('smtp_password'), PHP_EOL"
  10. Verify that the smtp_password is overridden correctly with drush ev "echo Drupal::configFactory()->get('smtp.settings')->get('smtp_password'), PHP_EOL"
rlhawk’s picture

Title: Add a Submodule That Provides Config Override Functionality » Add Ability to Override Configuration With Keys
rlhawk’s picture

This functionality has been added directly to the Key module, rather than as a submodule.

rlhawk’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.