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
There were already questions about Views restoration to default settings, but I did not see a simple answer — install a clean copy of Backdrop and make an export > import. I always have a...
How to reset wrong Lateral-Layout-Settings especially view "promoted content"
A PR is a Pull Request which is used in GitHub to request that code from a branch on your fork of a project repository is merged into the project. In Backdrop, these are linked to an issue by...
managing draft revisions while still having a version published
thanks for letting me know, I installed the package, set it up on a content type and found it wasn't working and was a little confused why i wasn't able to work on a draft post publishing...
managing draft revisions while still having a version published