Skip to content

ConfigHelper

App\Helpers\ConfigHelper

Get Configuration Value by Key

php
ConfigHelper::fresnsConfigByItemKey($itemKey, $langTag);
Parameter NameTypeRequiredDescription
itemKeyStringrequiredconfigs->item_key
langTagStringoptionalLanguage tag(can be omitted), only effective for multi-language configurations.
If it is a multi-language configuration and not provided, the default language value will be output.

Get Configuration Values by Key Array

php
ConfigHelper::fresnsConfigByItemKeys($itemKeys, $langTag);
Parameter NameTypeRequiredDescription
itemKeysArrayrequiredconfigs->item_key
langTagStringoptionalLanguage tag(can be omitted), only effective for multi-language configurations.
If it is a multi-language configuration and not provided, the default language value will be output.
Return Example
json
{
    "site_name": "Fresns",
    "default_language": "en",
    "default_timezone": "+8"
}

Determine File Configuration Type by Key

php
ConfigHelper::fresnsConfigFileValueTypeByItemKey($itemKey);
Parameter NameTypeRequiredDescription
itemKeyStringrequiredconfigs->item_key
Description
  • ID value is the file ID: the key is a number
  • URL value is the file URL: the key starts with http:// or https://

Get File Path by Key

php
ConfigHelper::fresnsConfigFileUrlByItemKey($itemKey);
Parameter NameTypeRequiredDescription
itemKeyStringrequiredconfigs->item_key
Description
  • Image output as imageConfigUrl
  • Video output as videoUrl
  • Audio output as audioUrl
  • Document output as documentPreviewUrl

Get Length Unit by langTag

php
ConfigHelper::fresnsConfigLengthUnit($langTag);
Parameter NameTypeRequiredDescription
langTagStringrequiredLanguage Tag

Query the language_menus key value in the configs table and output the lengthUnits parameter for the corresponding language tag.

Get Date Format by langTag

php
ConfigHelper::fresnsConfigDateFormat($langTag);
Parameter NameTypeRequiredDescription
langTagStringrequiredLanguage Tag

Query the language_menus key value in the configs table and output the dateFormat parameter for the corresponding language tag.

Released under the Apache-2.0 License