As I understand it, the current values of a component configuration are stored as JSON in the params field of the #__extensions database table, in the entry that matches the component name as element. Presumably the recommended way to obtain the current configuration is:
$params = ComponentHelper::getParams($element)
(although the user side application object has a method for obtaining the configuration without specifying the element, this seems not to exist on the admin side).
The configuration can be changed in software using:
The issue then is how to store the new configuration. Ideally one might use a method in Joomla, but I cannot find a suitable one. Does one exist?
Assuming the storing has to be done by a database update, I find (by experiment) that the $params object converted to string cannot be used in a SQL statement because of problems of character escaping. Although it makes legal SQL, the result is that Joomla can no longer handle the configuration. In order to get storage to work, I have derived the following:
$sql = "UPDATE #__extensions SET params = '%s' WHERE type = 'component' AND element = 'com_example'"; $json = str_replace('\\\\"', '\\\\\\"', addcslashes($this->params, '"')); $sql = sprintf($sql, $json);
This works for the fairly complex configuration I am using. But my question is, does it work for all possible configurations? And is there an easier way?