Description of the need
According to what @jenlampton suggested in https://github.com/backdrop/backdrop-issues/issues/2355 the config_clear() wrapper was introduced as the equivalent of variable_del(), which was also confirmed by @quicksketch' comment:
I would also avoid any abbreviation, "del" was used I imagine because it made "pretty" function names that were all the same length: variable_get/set/del. If we were to have wrappers for the delete method as well, I would be in favor of naming it
config_delete()(in addition toconfig_clear()for removing a single value).
However, if variable_del() did work well for cleaning all the database entries upon deletion of modules on Drupal 7, in Backdrop we have not only database entries, but actual configuration files. So implementing the hook_uninstall() in module_name.install file as, for example:
/**
* Implements hook_uninstall().
*/
function mymodule_index_uninstall() {
config_clear('mymodule.settings', 'mymodule_content_types');
}
only clears configuration entries in the respective file, it does not delete the file itself.
Proposed solution
I am filing this as a feature request in case if the config_clear() wrapper was never meant for deleting the config files, but only for clearing entries in config files. In this case, I suggest to introduce new config_delete() wrapper to actually delete the config files when modules get uninstalled.
In case if the config_clear() was meant not only delete the configuration lines, but also/instead delete the configuration files, then this should be re-classified as a bug report.
Until this issue is addressed the following code takes care of the configuration file:
/**
* Implements hook_uninstall().
*/
function $mymodule_uninstall() {
config('mymodule.settings')->delete();
}
Recent comments
Thank you for your answer. What I want to do is display usernames or user images in a menu, similar to many community websites. The basic menu that Backdrop currently provides is a "...
How can I display the username or user profile picture in the menu?
Just go to the menu where you want to add your link. Add your link and in the path search for "user". It's done. No need to use a token. Or perhaps this ? menu_attributes
How can I display the username or user profile picture in the menu?
Please can you provide more information about the use case for this and also a screenshot or mockup of what you are trying to achieve. There is a request here (https://github.com/backdrop-...
How can I display the username or user profile picture in the menu?