/** * Initialization * * Determine error handling configuration ans setup correspondent properties. * * This functions wiil be executes one time before first error/eception or never * if error/exception hasn't occur. */ static function init() { if (self::$rootDir) { return; } try { $c = Config::getInstance(); $root_dir = $c->root_dir; $data_dir = $c->data_dir; } catch (Exception $e) { $root_dir = dirname(dirname(__FILE__)); $data_dir = '/data'; } self::$rootDir = $root_dir; $textTemplate = $root_dir . $data_dir . '/exceptionTemplate.text.php'; $webTemplate = $root_dir . $data_dir . '/exceptionTemplate.web.php'; // errors will be logged if (self::iniToBool(ini_get('log_errors'))) { self::$logTemplate = $textTemplate; } // errors wiil be displayed if (self::iniToBool(ini_get('display_errors'))) { // in console(CLI) and Ajax we preffered to display errors in plain text self::$displayTemplate = php_sapi_name() == 'cli' || Controller::getInstance()->isAjax() ? $textTemplate : $webTemplate; } }