I have a singleton class used to initialise error_handling.
The class as is takes a Zend_Config object and optional $appMode in parameter, to allow overriding the def
Checkout
<?
class ErrorHandling{
private static $instance;
private static $_appMode; // not initialised in returned instance
private $_errorConfig;
private function __construct(array $config, $appMode = null){
$this->_errorConfig = $config;
if(isset($appMode)){
self::$_appMode = $appMode;
}else{
self::$_appMode = APPMODE;
}
}
private final function __clone(){}
public static function getInstance(array $config, $appMode = null){
if(! (self::$instance instanceof self)){
self::$instance = new ErrorHandling($config, $appMode);
}
return self::$instance;
}
public static function getAppMode() {
return self::$_appMode;
}
}
$e = ErrorHandling::getInstance(array('dev' => true), -255);
var_dump($e, ErrorHandling::getAppMode());
Is that your want?
Your could read here about difference between static
and self
- late static binding
You probably don't use any 5.3.x-Version of PHP. "Late Static Binding" (static::$_appMode
) is not available in any version before. Use self::$_appMode
instead. Its slightly different from static
, but in your case it should be OK. For further info read Manual: Late Static Binding