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

KeyDescriptionUsed byDefault value
net.stubbles.number.decimalsNumber of decimals for floating point operations.net::stubbles::ipo::request::filters::stubFloatFilternull
net.stubbles.ipo.session.fingerprintSaltThe hidden salt that can be used to make the session fingerprint secure.net::stubbles::ipo::session::stubPHPSessionEmpty string.
net.stubbles.util.log.classInstance of net::stubbles::util::log::stubLogData to be used by the factory.net::stubbles::util::log::stubLogDataFactorynet::stubbles::util::log::stubBaseLogData
net.stubbles.ipo.request.classImplementation of net::stubbles::ipo::request::stubRequest to usenet::stubbles::websites::stubFrontControllernet::stubbles::ipo::request::stubWebRequest
net.stubbles.ipo.session.classImplementation of net::stubbles::ipo::session::stubSession to usenet::stubbles::websites::stubFrontControllernet::stubbles::ipo::session::stubPHPSession
net.stubbles.ipo.session.nameName of the sessionnet::stubbles::websites::stubFrontControllerPHPSESSID
net.stubbles.websites.variantmanager.variantfactory.classClass of the net::stubbles::websites::variantmanager::stubVariantFactory to use.net::stubbles::websites::variantmanager::stubVariantsPreInterceptornet::stubbles::websites::variantmanager::stubXJConfVariantFactory
net.stubbles.websites.variantmanager.cookie.nameName of the cookie that should store the selected variantnet::stubbles::websites::variantmanager::stubVariantsPreInterceptorvariant
net.stubbles.websites.variantmanager.cookie.expiringDuration after the cookie that should store the selected variant will expirenet::stubbles::websites::variantmanager::stubVariantsPreInterceptor7776000 (90 days)
net.stubbles.websites.variantmanager.cookie.urlURL of the cookie that should store the selected variant net::stubbles::websites::variantmanager::stubVariantsPreInterceptornull (current domain)
net.stubbles.websites.variantmanager.cookie.pathPath of the cookie that should store the selected variant net::stubbles::websites::variantmanager::stubVariantsPreInterceptor/ (whole domain)
net.stubbles.languageDefault languagenet::stubbles::websites::xml::skin::stubDefaultSkinGeneratoren_EN
net.stubbles.filemodeMode for newly created directorieswherever mkdir() is used0700
net.stubbles.websites.memphis.templateDirDirectory where templates for the Memphis view engine are locatedMemphis view enginestubConfig::getPagePath() . '/../templates'