Example #1
0
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = static::load();
         if (!defined('GANTRY5_DEBUG')) {
             define('GANTRY5_DEBUG', self::$instance->debug());
         }
     }
     return self::$instance;
 }
Example #2
0
 /**
  * Setup a map of environments to their patterns and optionally debug environments
  *
  * @param array $map
  * @param array $debug	[= []]
  * @access public
  * @return void
  * @static
  */
 public static function setup(array $map, array $debug = [])
 {
     array_change_key_case($map, CASE_LOWER);
     static::$map = $map;
     if (!empty($debug)) {
         static::$debug = $debug;
     }
 }
 public static function isTestsDebug()
 {
     if (null === static::$debug) {
         $debug = getenv('SYMFONY_TESTS_DEBUG');
         if (false === $debug) {
             static::$debug = true;
         } else {
             static::$debug = filter_var($debug, FILTER_VALIDATE_BOOLEAN);
         }
     }
     return static::$debug;
 }
Example #4
0
 public static function connect()
 {
     // config
     $params = Config::get('database');
     // set debug mode
     static::$debug = Config::get('debug', false);
     // build dns string
     $dsn = 'mysql:dbname=' . $params['name'] . ';host=' . $params['host'];
     // try connection
     static::$dbh = new PDO($dsn, $params['username'], $params['password']);
     // set error handling to exceptions
     static::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     return true;
 }
Example #5
0
 /**
  * 初始化:创建Application
  * @access public
  * @param array $config设置
  */
 public static function createApplication($config = NULL)
 {
     if ($config === NULL) {
         throw new SYException('Configuration is required', '10001');
     } elseif (is_string($config)) {
         if (is_file($config)) {
             $config = (require $config);
         } else {
             throw new SYException('Config file ' . $config . ' not exists', '10002');
         }
     } elseif (!is_array($config)) {
         throw new SYException('Config can not be recognised', '10003');
     }
     //框架所在的绝对路径
     static::$frameworkDir = SY_ROOT;
     static::$rootDir = rtrim(str_replace('\\', '/', realpath(SY_ROOT . '../')), '/') . '/';
     //程序相对网站根目录所在
     $now = $_SERVER['PHP_SELF'];
     $dir = str_replace('\\', '/', dirname($now));
     $dir !== '/' && ($dir = rtrim($dir, '/') . '/');
     static::$siteDir = $dir;
     //网站根目录
     static::$webrootDir = substr(static::$rootDir, 0, strlen(static::$rootDir) - strlen(static::$siteDir)) . '/';
     //基本信息
     $config['cookie']['path'] = str_replace('@app/', $dir, $config['cookie']['path']);
     static::$app = $config;
     //应用的绝对路径
     static::$appDir = rtrim(str_replace('\\', '/', realpath(SY_ROOT . $config['dir'])), '/') . '/';
     if (isset($config['debug'])) {
         static::$debug = $config['debug'];
     }
     mb_internal_encoding($config['charset']);
     //是否启用CSRF验证
     if ($config['csrf']) {
         \sy\lib\YSecurity::csrfSetCookie();
     }
     //加载App的基本函数
     if (is_file(static::$appDir . 'common.php')) {
         require static::$appDir . 'common.php';
     }
     //开始路由分发
     static::router();
 }
Example #6
0
 public static function init()
 {
     static::$debug = ini_get('display_errors') ? true : false;
     // stop if there's already an error
     if ($error = error_get_last()) {
         terror::error($error['message'], $error['type'], $error['file'], $error['line']);
     }
     /*
     // switch off conventional error reporting…
     error_reporting(0);
     
     // …to run our own
     ini_set('display_errors', 0);
     */
     // set a global error handler
     set_error_handler(array('Terror', 'errorHandler'));
     // track fatal errors
     register_shutdown_function(array('Terror', 'shutdownHandler'));
     // catch all uncaugth exceptions
     set_exception_handler(array('Terror', 'exceptionHandler'));
 }
Example #7
0
 /**
  * Method: _init
  * Sets the Errorlevel based on the Configfile
  */
 public static function _init()
 {
     if (Config::getVal('error', 'debug') != 1) {
         static::$debug = true;
     }
     switch (Config::getVal('error', 'level')) {
         case 'notice':
             static::$error_level = E_NOTICE;
             break;
         case 'warning':
             static::$error_level = E_WARNING & ~E_NOTICE;
             break;
         case 'error':
             static::$error_level = E_ERROR;
             break;
         case 'all':
             static::$error_level = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING;
             break;
         default:
             static::$error_level = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING;
             break;
     }
 }
Example #8
0
 public static function connect()
 {
     // config
     $params = Config::get('database');
     // set default mysql port number
     if (empty($params['port'])) {
         $params['port'] = 3306;
     }
     // set default collation
     if (empty($params['collation'])) {
         $params['collation'] = 'utf8_bin';
     }
     // set debug mode
     static::$debug = Config::get('debug', false);
     // build dns string
     $dsn = 'mysql:dbname=' . $params['name'] . ';host=' . $params['host'] . ';port=' . $params['port'];
     // mysql driver options
     $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\' COLLATE ' . $params['collation']);
     // try connection
     static::$dbh = new PDO($dsn, $params['username'], $params['password'], $options);
     // set error handling to exceptions
     static::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     return true;
 }
Example #9
0
 /**
  * Controls whether Annotations are efficiently cached on the file system or not.
  *
  * @param $debug
  */
 public static function setDebug($debug)
 {
     // Need to recreate the instace.
     static::$instance = null;
     static::$debug = $debug;
 }
Example #10
0
 /**
  * @param null|bool $bool
  * @return bool
  */
 public static function debug($bool = null)
 {
     return is_bool($bool) ? static::$debug = $bool : static::$debug;
 }
 public function __construct()
 {
     $this->model = $this->getModel();
     if (InputHelper::handleInput("debug", false) !== false) {
         static::$debug = true;
     }
 }
Example #12
0
 public static function init($db, $userID = "", $debug = false)
 {
     static::$db = $db;
     static::$userID = $userID;
     static::$debug = $debug;
 }
Example #13
0
 /**
  * Sets the debug flag
  *
  * @static
  * @param bool $value
  */
 public static function setDebug($value)
 {
     static::$debug = (bool) $value;
 }
Example #14
0
 /**
  * Debug mode switch
  */
 public function debug($switch = true)
 {
     static::$debug = (bool) $switch;
     return $this->trace();
 }
Example #15
0
 /**
  * Parse a MPQ file
  *
  * @param  string  $filename
  * @param  boolean $autoparse
  * @param  integer $debug
  * @return void
  */
 public static function parse($filename, $autoparse = true, $debug = 0)
 {
     $obj = new static();
     $obj->filename = $filename;
     $obj->debug = $debug;
     if (!$obj::$cryptTable) {
         $obj::initCryptTable();
     }
     if (file_exists($obj->filename)) {
         $fp = fopen($obj->filename, 'rb');
         $contents = fread($fp, filesize($obj->filename));
         if ($obj->debug && $contents === false) {
             $obj->debug("Error opening file {$filename} for reading");
         }
         if ($contents !== false) {
             $obj->fileData = $contents;
         }
         fclose($fp);
     }
     if ($autoparse) {
         $obj->parseHeader();
     }
     return $obj;
 }
Example #16
0
 /**
  * Enables or disabled debug mode.
  * @param boolean  $debug
  * @return void
  */
 public static function setDebug($debug = false)
 {
     static::$debug = (bool) $debug;
 }
 public function __construct(Config $config = null)
 {
     if ($config !== null) {
         $this->setConfig($config);
     }
     $this->model = $this->getXmlModel();
     if (InputHelper::handleInput("debug", false) !== false) {
         static::$debug = true;
     }
 }
Example #18
0
 public static function setDebug($debug)
 {
     static::$debug = $debug;
 }
Example #19
0
 /** @param bool $pSwitch Turn debugging messages on/off. */
 public static function setDebug($pSwitch)
 {
     static::$debug = $pSwitch;
 }
 public static function debugMode()
 {
     static::$debug = true;
 }