I was using this modules code in one of my other modules and I wanted to override some of the config from settings.php This doesn't seem to work when you try it like this: https://git.drupalcode.org/project/high_contrast/blob/8.x-1.x/src/EventS...
For some reason the data from event is incorrect. Instead this works:
$config = \Drupal::config('high_contrast.settings');

In settings.php you have something like this:

$config['high_contrast.settings']['colors_background'] = '#000000';

Comments

hkirsman created an issue. See original summary.

neograph734’s picture

That makes sense... The configuration that the event receives is the configuration that has been saved (as that triggered the event). So those are the non-overridden values.
Feel free to provide a patch or commit directly. Issue and cause are explainable.

hkirsman’s picture

hkirsman’s picture

Status: Active » Needs review

Status: Needs review » Needs work
hkirsman’s picture

I think it failed because we are missing tests.

hkirsman’s picture

Status: Needs work » Needs review
neograph734’s picture

Status: Needs review » Needs work

Let's follow best practices and use dependency injection instead. It is already there for the file system.

neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new2.38 KB

I think this should have the same result.

Status: Needs review » Needs work
neograph734’s picture

Status: Needs work » Needs review

We have a passing test now, so this should no longer fail.

Status: Needs review » Needs work
neograph734’s picture

Status: Needs work » Needs review
StatusFileSize
new2.67 KB

Missed the use statement.

hkirsman’s picture

Looks good!
Also tested by adding
$config['high_contrast.settings']['colors_background'] = 'red';
to settings.php and saving form. Change was applied.

hkirsman’s picture

Status: Needs review » Reviewed & tested by the community

  • Neograph734 committed 22e3f9d on 8.x-1.x
    Issue #3117727 by Neograph734, hkirsman: Can't override config from...
neograph734’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed :)

Status: Fixed » Closed (fixed)

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