Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
klonos opened this issue Jun 20, 2024 · 4 comments

Comments

@klonos
Copy link
Member

klonos commented Jun 20, 2024

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:

  • a new state_set property as well, to match state_set()
  • config_del and state_del properties to allow deleting configuration
@klonos
Copy link
Member Author

klonos commented Jun 20, 2024

...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
Copy link

argiepiano commented Jun 20, 2024

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
Copy link
Member Author

klonos commented Jun 20, 2024

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
Copy link
Member

stpaultim commented Sep 5, 2024

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 (#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants