Hi there!
Thanks so much for writing this, this is one of those modules that I've wished I would just make the time to write, but never seem to be able to carve out time to do it. So thank YOU for taking the time to do it! :D
So, I think it would be helpful if you could specify to have it just output an array of variables and their settings instead of a variable_set call on each one. Even better would be if you could specify the module name and hook name for the variables. This would be very helpful in working with modules such as strongarm, where you are implementing a hook that returns an array of variables and their settings.
The nice thing about doing this, even if you aren't using strongarm, is that you can call the function on hook_enable & hook_disable like this (very helpful for features):
<?php
/**
* Implementation of hook_enable().
*/
function example_enable() {
foreach (_example_vars() as $key => $data) {
variable_set($key, $data);
}
}
/**
* Implementation of hook_enable().
*/
function example_disable() {
// Clean up variable settings.
foreach (array_keys(_example_vars()) as $key) {
variable_del($key);
}
}
?>
I may have some time to work on a patch for this if you'd be open to this sort of functionality.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | variable_dump_function_559234_7.diff | 4.47 KB | q0rban |
| #6 | variable_dump_function_559234_5.diff | 4.46 KB | q0rban |
| #5 | variable_dump_function_0.diff | 4.59 KB | q0rban |
| #3 | variable_dump_function.diff | 4.59 KB | q0rban |
| #2 | variable_dump_function.diff | 4.59 KB | q0rban |
Comments
Comment #1
q0rban commentedThought I'd document this, in case someone finds it useful. I guess you could simplify the above code even more if you wanted to:
Comment #2
q0rban commentedHere's a stab at it.
Comment #3
q0rban commentedminor fix.. Re-ordering the functions.
Comment #4
nancydruI'd love to see this feature included.
Comment #5
q0rban commentedRe-rolling patch, as the previous one failed for me.
Comment #6
q0rban commentedUm.. I accidentally attached the same file. Let me try that again. :/
Comment #7
q0rban commentedA few fixes.
Comment #8
karens commentedLooks useful, committed. Thanks!