Blesta Source Documentation

SettingsProcessor extends Helper

Settings Processor Helper

Provides processing and validation for complex settings, particularly those stored as JSON with multi-currency or range-based constraints.

Table of Contents

Properties

$components
$helpers
$models

Methods

__construct()
decodeJsonSetting() Decode JSON setting with error handling
encodeJsonSetting() Encode data to JSON format with error handling
formatDecimalValue() Format a decimal value with consistent precision
processCurrencyBasedSettings() Process currency-based settings (format and structure) No validation - use validateCurrencyBasedSettings() first if needed
validateCurrencyBasedSettings() Validate currency-based settings with min/max constraints
Properties
Methods

__construct()

public __construct() : mixed

decodeJsonSetting()

Decode JSON setting with error handling

public decodeJsonSetting(string $json_string) : array<string|int, mixed>
Parameters
$json_string : string

JSON string to decode

Return values
array<string|int, mixed>

Decoded array, or empty array on error

encodeJsonSetting()

Encode data to JSON format with error handling

public encodeJsonSetting(mixed $data) : string
Parameters
$data : mixed

Data to encode

Return values
string

JSON encoded string, or '}' on error

formatDecimalValue()

Format a decimal value with consistent precision

public formatDecimalValue(mixed $value[, int $precision = 4 ]) : string
Parameters
$value : mixed

The value to format

$precision : int = 4

Number of decimal places (default: 4)

Return values
string

Formatted decimal string

processCurrencyBasedSettings()

Process currency-based settings (format and structure) No validation - use validateCurrencyBasedSettings() first if needed

public processCurrencyBasedSettings(array<string|int, mixed> $input_data) : array<string|int, mixed>
Parameters
$input_data : array<string|int, mixed>

Raw input data keyed by currency code, with each value containing 'min' and/or 'max' keys

Return values
array<string|int, mixed>

Processed settings array ready for JSON encoding

validateCurrencyBasedSettings()

Validate currency-based settings with min/max constraints

public validateCurrencyBasedSettings(array<string|int, mixed> $input_data) : array<string|int, mixed>
Parameters
$input_data : array<string|int, mixed>

Raw input data keyed by currency code, with each value containing 'min' and/or 'max' keys

Return values
array<string|int, mixed>

Empty array if valid, or errors keyed by currency containing error keys

Tags
subpackage

helpers.settingsprocessor

copyright

Copyright (c) 2025, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results