class Settings implements ExtenderInterface

Methods

serializeToForum(string $attributeName, string $key, callable|string|null $callback = null)

Serialize a setting value to the ForumSerializer attributes.

default(string $key, mixed $value)

Set a default value for a setting.

resetWhen(string $key, callable|string $callback)

Delete a custom setting value when the callback returns true.

registerLessConfigVar(string $configName, string $key, callable|string|null $callback = null)

Register a setting as a LESS configuration variable.

resetJsCacheFor(string $setting)

Register a setting that should trigger JS cache clear when saved.

void
extend( Container $container, Extension|null $extension = null)

No description

Details

Settings serializeToForum(string $attributeName, string $key, callable|string|null $callback = null)

Serialize a setting value to the ForumSerializer attributes.

Parameters

string $attributeName : The attribute name to be used in the ForumSerializer attributes array.
string $key : The key of the setting.
callable|string|null $callback : Optional callback to modify the value before serialization. The callback can be a closure or an invokable class, and should accept: - mixed $value: The value of the setting. The callable should return: - mixed $value: The modified value.

Return Value

Settings

Settings default(string $key, mixed $value)

Set a default value for a setting.

Replaces inserting the default value with a migration.

Parameters

string $key : The setting key, must be unique. Namespace it with the extension ID (example: 'my-extension-id.setting_key').
mixed $value : The setting value.

Return Value

Settings

Settings resetWhen(string $key, callable|string $callback)

Delete a custom setting value when the callback returns true.

This allows the setting to be reset to its default value.

Parameters

string $key : The key of the setting.
callable|string $callback : The callback to determine if the setting should be reset.

Return Value

Settings

Settings registerLessConfigVar(string $configName, string $key, callable|string|null $callback = null)

Register a setting as a LESS configuration variable.

Parameters

string $configName : The name of the configuration variable, in hyphen case.
string $key : The key of the setting.
callable|string|null $callback : Optional callback to modify the value. The callback can be a closure or an invokable class, and should accept: - mixed $value: The value of the setting. The callable should return: - mixed $value: The modified value.

Return Value

Settings

Settings resetJsCacheFor(string $setting)

Register a setting that should trigger JS cache clear when saved.

Parameters

string $setting : The key of the setting.

Return Value

Settings

void extend( Container $container, Extension|null $extension = null)

Parameters

Container $container
Extension|null $extension

Return Value

void