PHP:
$editorToolbarConfig = $this->app->options()->editorToolbarConfig;
$optionValue = [
'toolbarButtons' => null,
'toolbarButtonsMD' => null,
'toolbarButtonsSM' => null,
'toolbarButtonsXS' => null
];
foreach ($editorToolbarConfig AS $type => $toolbar)
{
$toolbar = implode('|', $toolbar);
$toolbar = preg_replace("/(xfInsert)/", '$0|-vs|mh_hide ', $toolbar);
$toolbar = explode('|', $toolbar);
$optionValue[$type] = $toolbar;
}
/** @var Option $optionRepo */
$optionRepo = \XF::repository('XF:Option');
$optionRepo->updateOption('editorToolbarConfig', $optionValue);
\XF::repository('XF:Editor')->rebuildEditorDropdownCache();
Thus, this function works as follows as arguments:
- Setting name
- Value
A simple example of updating settings:
PHP:
$options = \XF\Util\Arr::arrayFilterKeys(
$this->filter('options', 'array'),
['boardTitle', 'boardUrl', 'contactEmailAddress', 'homePageUrl', 'collectServerStats'],
true
);
if (!empty($options['contactEmailAddress']))
{
$options['defaultEmailAddress'] = $options['contactEmailAddress'];
}
if (!empty($options['boardUrl']))
{
$options['options']['boardUrl'] = rtrim($options['boardUrl'], '/');
}
/** @var \XF\Repository\Option $optionRepo */
$optionRepo = $this->repository('XF:Option');
// if applicable, updating collectServerStats will enqueue stats collection automatically
$optionRepo->updateOptions($options);
But maybe we need to update the setting by skipping its check.
PHP:
$serverStatsConfig = $this->app->options()->collectServerStats;
$serverStatsConfig['last_sent'] = time();
/** @var \XF\Repository\Option $optionRepo */
$optionRepo = $this->app->repository('XF:Option');
// skip verifying the option here as only last_sent will have changed
$optionRepo->updateOptionSkipVerify('collectServerStats', $serverStatsConfig);