Settings

This section will go over how to utilize the settings values you have defined.

Setting Interface

This section will go over the \Anomaly\SettingsModule\Setting\Contract\SettingInterface class.

SettingInterface::field()

The field method returns the field type instance for the value or null if the value's field no longer exists.

Returns: \Anomaly\Streams\Platform\Addon\FieldType\FieldType or null
Example
$setting = $settings->get('anomaly.module.files::max_upload_size');

if ($field = $setting->field()) {
    echo $field->getValue();
}

Setting Repository

This section will go over the \Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface class.

SettingRepositoryInterface::get()

The get method returns the setting instance.

Returns: \Anomaly\SettingsModule\Setting\Contract\SettingInterface
Arguments
Key Required Type Default Description
$key true string none The setting key.
Example
$max = $settings->value('anomaly.module.files::max_upload_size');

echo $max->getValue();
SettingRepositoryInterface::set()

The set method allows you to set a setting value.

Values are passed through the setting's field modifier.

Returns: boolean
Arguments
Key Required Type Default Description
$key true string none The setting key.
$value true mixed none The setting value.
Example
$settings->set('anomaly.module.files::max_upload_size', 32);
SettingRepositoryInterface::value()

The value method returns the value as the setting field type normally would with getType.

Returns: mixed
Arguments
Key Required Type Default Description
$key true string none The setting key.
$default false mixed null The default value.
Example
$value = $settings->value('anomaly.module.files::max_upload_size', 2);
SettingRepositoryInterface::presenter()

The presenter method returns the setting value's field type presenter or null if the value's field no longer exists.

Returns: \Anomaly\Streams\Platform\Addon\FieldType\FieldTypePresenter or null
Arguments
Key Required Type Default Description
$key true string none The setting key.