backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 40 forks source link

Recipes: Allow setting/deleting configuration (and states?) via properties in .info files (without having to write PHP code) #6617

Open klonos opened 4 months ago

klonos commented 4 months ago

This is a sibling issue to #6616, which will help with #5240 and #6595.

We should also support a new config_set property in .info file, which would allow the same tasks as bee cset or the config_set() function to be performed during recipe installation/execution.

Perhaps also consider the following:

klonos commented 4 months ago

...the above proposal would be an MVP, and would be helpful when only a small set of configuration changes need to be performed. For example the equivalent of running bee cset system.core admin_theme gin, which sets Gin as the default admin theme, would look something like the following as a .info property implementation:

config_set[system.core][admin_theme] = gin

We should eventually support something similar to the config/sync directory in Drupal - see change record here:

You can create your own install profile and export your configuration to a config/sync directory inside the install profile.

This would be a follow-up issue though. For now, baby-steps.

argiepiano commented 4 months ago

We should also support a new config_set property in .info file

That's an intriguing proposal that would have saved me some coding time (I currently do this type of things in hook_install()). I'm wondering if something like this could be first tested as a contrib module.

klonos commented 4 months ago

The ultimate goal of this proposal is to eventually allow recipes 2.0 (#6595) to be reduced to a .info file as much as possible, and to eliminate the need for PHP code (.install or .module files) or at least reduce it to the absolute minimum.

If you look in the .install file of the https://github.com/backdrop-contrib/digital_agency contrib project for example, you will see an entire section of this:

    config_set('system.core', 'site_name', 'My Digital Agency');
    config_set('layout.layout.home', 'content.9bd5a524-3670-4922-8b12-18b00a2858b9.data.settings.block_settings.menu', 'main-menu');
    config_set('layout.layout.default', 'content.84c43df4-1165-4faf-8700-c362a7153c0b.data.settings.block_settings.menu', 'main-menu');
    config_set('layout.layout.default', 'layout_template', 'boxton');
    config_set('layout.layout.services', 'content.7a914d95-dd2b-4c5b-9334-52a024a529ae.data.settings.block_settings.menu', 'main-menu');
    // Changing text and image in front page hero block.
    config_set('layout.layout.home', 'content.094cbc03-d088-4b3c-8361-977733540ae8.data.settings.title', 'Digital Agency Website');
    config_set('layout.layout.home', 'content.094cbc03-d088-4b3c-8361-977733540ae8.data.settings.image_path', '/files/hero/flamingo-background.webp');
    config_set('nice_menus.settings', 'nice_menus_menu_1', 'main-menu:0');
    config_set('nice_menus.settings', 'nice_menus_depth_1', '0');

    // Changing 'published on' date format for posts.
    config_set('node.type.post', 'settings.node_submitted_format', 'By [node:author], [node:created:date_only]');

    // Adding mini-layout to footer of available layouts.
    config_set('layout.layout.projects', 'content.' . $projects_block->uuid . '.data.settings.title_display', 'none');
    config_set('layout.layout.default', 'content.' . $default_block->uuid . '.data.settings.title_display', 'none');
    config_set('layout.layout.home', 'content.' . $home_block->uuid . '.data.settings.title_display', 'none');
    config_set('layout.layout.services', 'content.' . $services_block->uuid . '.data.settings.title_display', 'none');

That specific recipe does a lot more, like adding files/images, creating nodes, adding blocks to layouts, which should also be eventually allowed via .info "recipe commands" ...but baby steps, as I said.

stpaultim commented 2 months ago

That's an intriguing proposal that would have saved me some coding time (I currently do this type of things in hook_install()). I'm wondering if something like this could be first tested as a contrib module.

The ultimate goal of this proposal is to eventually allow recipes 2.0 (https://github.com/backdrop/backdrop-issues/issues/6595) to be reduced to a .info file as much as possible, and to eliminate the need for PHP code (.install or .module files) or at least reduce it to the absolute minimum.

So, could the code for this be put into the "Recipes" module. All recipes would be dependent upon the recipes module, for now. I see this as an eventual core feature, but lately I've been coming up with ideas that would facilitate recipes and could be bundled in the recipes contrib module for testing.

Just a thought.

I agree, that this would be good for recipes. In some of my recent recipes, I've included a bunch of configuration settings in the .install file. Not sure how much it helps to move them to the .info file, but it can't hurt.