Here's a typical update hook where we need to update the default config of a view provided by core:
function somemodule_update_1007() {
$data = array(
... 100s OF LINES OF CODE HERE ...
);
$config = config('some.config.file');
if ($config->isNew()) {
$config->setData($data);
$config->save();
}
}
I have always found this to be very annoying, because a) a dev has to convert the contents of the .json file to an array (to be used as the value of $data), and b) we are adding 100s of lines of code to .install files, which makes them unreadable.
Why are we not doing something like this instead?:
function somemodule_update_1007() {
$new_config_file = backdrop_get_path('module', 'somemodule') . '/config/some.config.file.json';
$data = json_decode(file_get_contents($new_config_file), TRUE);
$config = config('some.config.file');
if ($config->isNew()) {
$config->setData($data);
$config->save();
}
}
GitHub Issue #:
3347
Recent comments
Security question: If we have found (or been informed of) a security issue in our own modules, do we just go ahead and put out a patch? Or is there some other process? What...
Weekly Meetings Dec 3rd 2026
I think a good place to start if you have ideas to share a mock-up of what it might look like. What I mean is not creating a new mock-up for the directory page. When we...
Improving Theme Presentation and Promoting Backdrop CMS
In case there's time left, three topics for the dev meeting: Simpletest in GH Our testing framework needs some attention. 3 tests constantly failing, but only in GH runners. Not...
Weekly Meetings Dec 3rd 2026