Exemple #1
0
 /**
  * How to handle caught errors: log if in production, debug if in development.
  * Is also the registered handler for dealing with uncaught exceptions.
  *
  * @access public
  * @param Exception $Exception
  * @return void
  */
 public function log($Exception)
 {
     if (!$Exception) {
         $Exception = $this;
     }
     $trace = $Exception->getTrace();
     $method = $trace[0]['class'] . $trace[0]['type'] . $trace[0]['function'] . '()';
     $response = $method . ': ' . $Exception->getMessage();
     if ($code = $Exception->getCode()) {
         $response .= ' (Code: ' . $code . ')';
     }
     Debugger::error($Exception->getCode(), $response, $Exception->getFile(), $Exception->getLine());
 }
Exemple #2
0
 /**
  * Initialize all classes required for runtime. Master initialize method.
  *
  * @access public
  * @return void
  * @static
  */
 public static function initialize()
 {
     // Try and autoload from include_paths first
     spl_autoload_register();
     spl_autoload_register('\\titon\\core\\App::autoload');
     // Initialize core components
     Environment::initialize();
     Debugger::initialize();
     Router::initialize();
     // Get super globals
     $get = $_GET;
     $post = $_POST;
     $files = array();
     if (!empty($_FILES)) {
         foreach ($_FILES as $model => $data) {
             foreach ($data as $meta => $values) {
                 $keys = array_keys($values);
                 $files[$model][$keys[0]][$meta] = $values[$keys[0]];
             }
         }
     }
     // Clear magic quotes, just in case
     if (get_magic_quotes_gpc() > 0) {
         $stripSlashes = function ($data) {
             return is_array($data) ? array_map($stripSlashes, $data) : stripslashes($data);
         };
         $get = $stripSlashes($get);
         $post = $stripSlashes($post);
         $files = $stripSlashes($files);
     }
     static::$data = array_merge_recursive($post, $files);
     static::$globals = array('_GET' => $get, '_POST' => $post, '_FILES' => $files, '_SERVER' => $_SERVER, '_ENV' => $_ENV);
 }
Exemple #3
0
 /**
  * Apply settings to the current loaded configuration.
  * If debug is being set, apply the error reporting rules.
  *
  * @access public
  * @param string $key
  * @param mixed $value
  * @return void
  * @static
  */
 public static function set($key, $value)
 {
     if ($key === 'debug') {
         $key = 'Debug.level';
         if ($value == 0) {
             Debugger::errorReporting(Debugger::ERRORS_OFF);
         } else {
             Debugger::errorReporting(Debugger::ERRORS_ON);
         }
     }
     static::$__config = Set::insert(static::$__config, (string) $key, $value);
 }