Using and configuring the registry
Usage
Various classes in Stubbles use the net::stubbles::lang::stubRegistry class for reading global configuration values. This configuration values can be retrieved from the registry via their key:
<?php $configValue = stubRegistry::getConfig('configKey'); ?>
This will assign the configuration value stored under configKey to the variable $configValue. If no value associated with the key exist, the variable will be null after this assignment.
It is also possible to use default values:
<?php $configValue = stubRegistry::getConfig('configKey', 'default'); ?>
In this case $configValue will have the value default if no value is associated with the key. If one is associated, $configValue will be set to this value.
Initialize the registry
To configure the registry, a net::stubbles::lang::initializer::stubRegistryInitializer can be used. A concrete implementation of this is the net::stubbles::lang::initializer::stubRegistryXJConfInitializer which uses the config file available at config/xml/config.xml to initialize the registry:
<?php $registryInitializer = new stubRegistryXJConfInitializer(); $registryInitializer->init(); ?>
After these two steps have been done the registry is fully usable.
Different configuration files
It is possible to have several different configuration files for the registry. The default is config/xml/config.xml, but you can create additional ones, e.g. something like config/xml/config-cli.xml. To let the initializer read from this file you just need one additional line:
<?php $registryInitializer = new stubRegistryXJConfInitializer(); $registryInitializer->setConfigSource('config-cli'); $registryInitializer->init(); ?>
Now the initializer will read from config/xml/config-cli.xml instead of config/xml/config.xml.
Create your own initializer
In case you are not happy with configuring in XML and using the {{{net::stubbles::lang::initializer::stubRegistryXJConfInitializer you may create your own initializer. It just has to implement the net::stubbles::lang::initializer::stubRegistryInitializer interface. Within the init method you can do whatever you like to fill the net::stubbles::lang::stubRegistry class with values.
List of used configuration values
| Key | Description | Used by | Default value |
| net.stubbles.number.decimals | Number of decimals for floating point operations. | net::stubbles::ipo::request::filters::stubFloatFilter | null |
| net.stubbles.ipo.session.fingerprintSalt | The hidden salt that can be used to make the session fingerprint secure. | net::stubbles::ipo::session::stubPHPSession | Empty string. |
| net.stubbles.util.log.class | Instance of net::stubbles::util::log::stubLogData to be used by the factory. | net::stubbles::util::log::stubLogDataFactory | net::stubbles::util::log::stubBaseLogData |
| net.stubbles.ipo.request.class | Implementation of net::stubbles::ipo::request::stubRequest to use | net::stubbles::websites::stubFrontController | net::stubbles::ipo::request::stubWebRequest |
| net.stubbles.ipo.session.class | Implementation of net::stubbles::ipo::session::stubSession to use | net::stubbles::websites::stubFrontController | net::stubbles::ipo::session::stubPHPSession |
| net.stubbles.ipo.session.name | Name of the session | net::stubbles::websites::stubFrontController | PHPSESSID |
| net.stubbles.websites.variantmanager.variantfactory.class | Class of the net::stubbles::websites::variantmanager::stubVariantFactory to use. | net::stubbles::websites::variantmanager::stubVariantsPreInterceptor | net::stubbles::websites::variantmanager::stubXJConfVariantFactory |
| net.stubbles.websites.variantmanager.cookie.name | Name of the cookie that should store the selected variant | net::stubbles::websites::variantmanager::stubVariantsPreInterceptor | variant |
| net.stubbles.websites.variantmanager.cookie.expiring | Duration after the cookie that should store the selected variant will expire | net::stubbles::websites::variantmanager::stubVariantsPreInterceptor | 7776000 (90 days) |
| net.stubbles.websites.variantmanager.cookie.url | URL of the cookie that should store the selected variant | net::stubbles::websites::variantmanager::stubVariantsPreInterceptor | null (current domain) |
| net.stubbles.websites.variantmanager.cookie.path | Path of the cookie that should store the selected variant | net::stubbles::websites::variantmanager::stubVariantsPreInterceptor | / (whole domain) |
| net.stubbles.language | Default language | net::stubbles::websites::xml::skin::stubDefaultSkinGenerator | en_EN |
| net.stubbles.filemode | Mode for newly created directories | wherever mkdir() is used | 0700 |
| net.stubbles.websites.memphis.templateDir | Directory where templates for the Memphis view engine are located | Memphis view engine | stubConfig::getPagePath() . '/../templates' |
