Basically it supports key/value pairs of data, which can be retrieved out of Midgard Parameters. In this case it would make the key/values a string/string pair with a length limit of 255 characters. Since the current implementation only supports read-access to the configuration data, this is a negligible fact, in reality it supports all valid PHP data types as key or data values, as long it is allowed to use the keys as array index elements.
This class is designed to manage parameter like key/value configuration data. The class makes no assumption about the value type of keys or values, any valid PHP data type is allowed. Two different sets of configuration options are stored within the class, the "global" and the "local" configuration.
The global configuration must include all possible configuration parameters with their default values. These data is fixed and cannot be changed after object instantiation. Aimed specifically at MidCOM is the second set of configuration data, the "local" parameters. It gives you a way of explicitly overwrite a part of the configuration data with localized values. This customization data can be overwritten at wish by deliberately resetting it to the defaults or by importing a new one over the existing local configuration.
Configuration data can be delivered in two ways: The easiest way is using a associative array that will be used as configuration. Alternatively you can specify both a MidgardObject and a MidCOM Path which is used to fetch configuration data.
Any configuration key in the local configuration, which is not present in the global "template", will be logged as a warning. This should normally not happen. Originally, this case threw a critical error, but that made upgrading configurations quite difficult.
Two sources can be specified:
First, if passed a single associative array to the constructor, it will use its contents as global configuration.
Alternatively you can specify any Midgard object and a parameter domain. It will then use the contents of this domain as global configuration.
mixedEither an associative array or a reference to a Midgard object.
mixedEither null or the name of a Parameter domain.
stringThe configuration key to check for.
booleanTrue, if the key is available, false otherwise.
If $key exists in the configuration data, its value is returned to the caller. If the value does not exist, the boolean value false will be returned. Be aware that this is not always good for error checking, since "false" is a perfectly good value in the configuration data. Do error checking with the function exists (see below).
stringThe configuration key to query.
mixedIts value or false, if the key doesn't exist.
ArrayThe complete current configuration.
If $reset is set, the local configuration will be cleared before the new set is imported, if not, the new data is merged with the old local configuration, overwriting duplicates. During import each configuration key will be checked against the global configuration values. If an unknown value is found, import will be aborted and no changes to the configuration is done.
After import the cache array will be updated, reset is done by reset_local.
arrayThe new local parameters
booleanIf set to true, the current local configuration will be discarded first.
To import configuration data from a Midgard Object, use this method. As in the respective constructor it will retrieve the configuration data in the parameter domain $path of $object. Unlike the constructor this function will store the data in the local configuration.
\MidgardObjectThe object from which to import data.
stringThe parameter domain to query.
booleanShould the existing local config be overridden or merged
Since the local array must only include configuration parameters that are included in the global configuration, this function is used to check a local array against the current global configuration. true/false is returned accordingly.
The flag $global controls whether the global or the local configuration should be updated. No control whether an update of the global data is allowed is done here, the caller has to do this. This function will update the config data cache array. If it stores global configuration data it will automatically erase the local configuration data.
Any error such as invalid configuration data will trigger a MidCOM error.
booleanSet to true to replace the global configuration.