It would be nice if strongarm provided a hook for 'weakarm' variables. The hook would return an array of variables that act more as a set of initial defaults, and can always be overridden by a database value, unlike hook_strongarm which are enforced by default. Make sense?

CommentFileSizeAuthor
#4 strongarm_561382_4.diff2.56 KBq0rban

Comments

dmitrig01’s picture

Status: Active » Closed (won't fix)

there's a nifty function that does this already - it's called variable_set

q0rban’s picture

Status: Closed (won't fix) » Active

So you don't see the value of having some default values for a feature or something that are automatically overridden if there is a value in the DB? Replaces this logic:

if (is_null(variable_get('some_var', NULL))) {
  variable_set('some_var', '[insert default value here]');
}
Macronomicus’s picture

Im keen to try the variable_set method in my feature but there may be an issue to solve first.

I want to add vars for logical defaults, but not have them erase any changes the user may have made since the last version of the feature was installed when they do an update of the feature.

Im sort of torn because I can be sure strongarm will track this and give the option to over-ride with notices... but I'm not sure all that is needed for setting pathauto & content_type tweaks that we only want an initial injection of.

Did you get any further with your idea q0rban?

q0rban’s picture

Status: Active » Needs work
StatusFileSize
new2.56 KB

Starting work on this. Still needs lots of work but I wanted to post what I had here for when I pick it back up again. I think I may have to completely rewrite the structure of the var_conf cache in order for this to work though, as right now the form_alter disables form elements for all strongarm/weakarm vars, and we need it to only do it on strongarm vars.

q0rban’s picture

Status: Needs work » Closed (duplicate)
Macronomicus’s picture

Cool .. thanks for the link!