Settings Manager

The SettingsManager allows you to easily store key/value based configuration settings based on module components and also optionally bound to a contentcontainer (e.g. users or spaces).

If you need to categorize key names, use this syntax: category.subcategory.camelCaseKeyName

The SettingsManager component is automatically added all to humhub\components\Module classes.

Module settings

Get desired module / application instance:

$module = Yii::$app;
// or
$module = Yii::$app->getModule('polls');
// or
$module = $controller->module;

Create or update existing setting in settings manager:

$module->settings->set('key', $value);

Get value of setting manager:

$value = $module->settings->get('key');

Delete setting:

// or
$module->settings->set('key', null);

ContentContainer related settings

If you want to store settings related to an user or space - use the ContentContainerSettingsManager:

$module->settings->contentContainer($user)->set('key', $value);

Shortcuts for currently logged in user settings:

$module->settings->user()->set('key', $value);

Shortcuts for current space settings: Note: This is only available if current controller is instance of ContentContainerController.

$module->settings->space()->set('key', $value);