Configuration

Data can be saved in the shop database without requiring a module specific table to be created.

The table configuration contains a list of key => value(s) properties which can be accessed from anywhere, including in a module. The Configuration class is the interface allowing each module developer to get or store data in this table.

Store configuration data

Configuration::updateValue(string $key, mixed $value);

$key will be the reference to your data to reuse later. $value can be any scalar type (int, string, bool, array…).

Check a configuration data exists

Configuration::hasKey(string $key);

$key is the name of the configuration data to check. The method returns true is the data exists, false otherwise.

Retrieve configuration data

Single key

Configuration::get(string $key);

With $key as the data to retrieve. If the key does not exist, the returned value will be null.

Example:

Configuration::get('PS_VERSION_DB');

==> '1.7.4.0'

Multiple keys

Configuration::getMultiple(array $keys);

With $keys as an array of keys to retrieve.

This returns an array, containing the values stored in the configuration table or null if a key does not exist.

Example:

Configuration::getMultiple(array('PS_VERSION_DB', 'UNKNOWN_KEY'));

==> array(
  'PS_VERSION_DB' => '1.7.4.0',
  'UNKNOWN_KEY' => null,
)

Use widgets