2012-08-04 10:40:48 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
|
|
|
* http://www.mysqldumper.net
|
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage Registry
|
|
|
|
* @version SVN: $Rev$
|
|
|
|
* @author $Author$
|
|
|
|
*/
|
|
|
|
/**
|
2012-08-05 17:05:08 +00:00
|
|
|
* Registry
|
2012-08-04 10:40:48 +00:00
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage Registry
|
|
|
|
*/
|
|
|
|
class Msd_Registry extends Zend_Registry
|
|
|
|
{
|
2012-08-08 22:36:28 +00:00
|
|
|
/**
|
|
|
|
* Key for the configuration filename. This is used inside the registry.
|
|
|
|
*
|
|
|
|
* @const string
|
|
|
|
*/
|
2012-08-21 20:22:56 +00:00
|
|
|
const CONFIG_FILENAME_KEY = 'configFilename';
|
2012-08-08 22:36:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Key for the dynamic configuration. This is used inside the registry.
|
|
|
|
*
|
|
|
|
* @const string
|
|
|
|
*/
|
2012-08-22 16:43:15 +00:00
|
|
|
const DYNAMIC_CONFIG_KEY = 'dynamic';
|
2012-08-08 22:36:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Key for the configuration. This is used inside the registry.
|
|
|
|
*
|
|
|
|
* @const string
|
|
|
|
*/
|
2012-08-22 16:43:15 +00:00
|
|
|
const CONFIG_KEY = 'config';
|
2012-08-08 22:36:28 +00:00
|
|
|
|
2012-08-04 10:40:48 +00:00
|
|
|
/**
|
|
|
|
* Returns the config instance if it has been registered, returns null otherwise.
|
|
|
|
*
|
|
|
|
* @return Msd_Config|null
|
|
|
|
*/
|
|
|
|
public static function getConfig()
|
|
|
|
{
|
2012-08-08 22:36:28 +00:00
|
|
|
if (self::isRegistered(self::CONFIG_KEY)) {
|
|
|
|
return self::get(self::CONFIG_KEY);
|
2012-08-04 10:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a Msd_Config instance.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*
|
|
|
|
* @param Msd_Config $config Configuration
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function setConfig(Msd_Config $config)
|
|
|
|
{
|
2012-08-08 22:36:28 +00:00
|
|
|
self::set(self::CONFIG_KEY . '', $config);
|
2012-08-04 10:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the dynamic config if it has been registered.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*
|
|
|
|
* @return Msd_Config_Dynamic|null
|
|
|
|
*/
|
|
|
|
public static function getDynamicConfig()
|
|
|
|
{
|
2012-08-08 22:36:28 +00:00
|
|
|
if (self::isRegistered(self::DYNAMIC_CONFIG_KEY)) {
|
|
|
|
return self::get(self::DYNAMIC_CONFIG_KEY);
|
2012-08-04 10:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers the dynamic configuration.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*
|
|
|
|
* @param Msd_Config_Dynamic $config Dynamic configuration.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function setDynamicConfig(Msd_Config_Dynamic $config)
|
|
|
|
{
|
2012-08-08 22:36:28 +00:00
|
|
|
self::set(self::DYNAMIC_CONFIG_KEY, $config);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the current configuration file.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function getConfigFilename()
|
|
|
|
{
|
|
|
|
if (self::isRegistered(self::CONFIG_FILENAME_KEY)) {
|
|
|
|
return self::get(self::CONFIG_FILENAME_KEY);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the name of the current configuration file.
|
|
|
|
*
|
|
|
|
* @param string $configFilename Name of configuration file.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function setConfigFilename($configFilename)
|
|
|
|
{
|
|
|
|
self::set(self::CONFIG_FILENAME_KEY, $configFilename);
|
2012-08-04 10:40:48 +00:00
|
|
|
}
|
|
|
|
}
|