Application Settings
The config
class is responsible for managing (adding/editing) application settings. All methods of this class are static.
Website Settings
Website settings refer to the settings that are editable through forms in the admin panel. The data management for these settings is done through the following methods of the config
class:
config::get
- retrieves a setting (or multiple settings) by key
config::set
- changes a setting (or multiple settings) by key without saving, only within the current request
config::save
- saves a setting (or multiple settings) by key
When working with website settings that are associated with a specific application module, the Module
component provides methods for bulk loading and saving settings for that module:
$this->configLoad
- retrieves all module settings
$this->configSave
- saves module settings by key (one or multiple)
Types of Settings
Website settings can be static or dynamic.
Static settings are cached and retrieved from the cache until the data is changed through forms in the admin panel or when the save
method is called.
Dynamic settings are loaded with each request and are mainly used to store various types of counters, such as an "unmoderated comments" counter.
To work with dynamic settings in the above-mentioned methods, the $dynamic
parameter needs to be used. Additionally, the config::saveCount
method is available to update the counter value by key.
The storage of website settings is performed in the TABLE_CONFIG
table and is also cached in a file.
System Settings
System settings refer to settings that are not editable through the admin panel and are configured once during application installation on the server.
The storage of system settings data is done in the file /config/sys.php. The settings can be changed by editing this file.
To access these settings, the following method is provided:
config::sys
- retrieves a system setting (or multiple settings) by key/prefix key
System settings include the project domain, database access, email settings, localization settings, and others.
When configuring the project on the server, it is recommended to restrict write permissions to the file from php.
Many settings, such as the number of entries in lists or pre-/post-moderation, are configured in the "Website Settings / System Settings" section. In code, they usually look like this:
config::sysAdmin('contacts.captcha', true, TYPE_BOOL);
Social Media Authentication Settings
The settings for interacting with social media are specified in the admin panel under the section "Website Settings / System Settings / Users / Social Media".