* @license PHP License * @package WB * @subpackage base */ /** * Configure class loader * * @version 0.1.3 * @package WB * @subpackage base */ class WBClass_Configurator extends WBClass implements WBParam_Observer { /** * keep reference to singleton */ static protected $_instance = null; /** * Static constructor * * Don't do anything */ static public function staticConstruct() { } /** * receive singleton instance * * @return WBClass_Configurator */ static public function start() { if (self::$_instance) { return self::$_instance; } self::$_instance = new WBClass_Configurator(); return self::$_instance; } /** * private constructor * * setup as parameter observer */ private function __construct() { WBParam::set('wb/class/includepath', WBClass::$_incDir); WBParam::set('wb/class/local', WBClass::$_locals); $autoload = WBParam::get('wb/class/autoload', false); WBClass::registerAutoload($autoload); WBParam::attach('wb/class/phpincludepath', $this); WBParam::attach('wb/class/includepath', $this); WBParam::attach('wb/class/local', $this); WBParam::attach('wb/class/autoload', $this); // set PHP include path $incPath = array( '.', WBParam::get('wb/dir/system') . '/include/pear/include' ); $incPath = WBParam::get('wb/class/phpincludepath', $incPath); WBParam::set('wb/class/phpincludepath', $incPath); } /** * Interface on set for parameter * * Implement things to be done when parameter is set * * @param string $name * @param mixed $value * @return bool true on success */ public function notifyOnSet($name, $value) { switch( $name ) { case 'wb/class/local'; WBClass::updateLocals($value); break; case 'wb/class/phpincludepath'; if (!is_array($value)) { $value = explode(PATH_SEPARATOR, $value); } set_include_path(implode(PATH_SEPARATOR, $value)); break; case 'wb/class/includepath'; WBClass::updateIncDir($value); break; case 'wb/class/autoload'; WBClass::registerAutoload($value); break; default: break; } return true; } } ?>