コード例 #1
0
ファイル: App.php プロジェクト: 645248882/CocoPHP
 public static function getInstance()
 {
     if (!self::$_instance && !is_object(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #2
0
ファイル: exception.php プロジェクト: hitzheng/ares
 /**
  * 全局异常处理
  * 异常有两个来源
  * 1. 通过set_exception_handler设置的全局未捕获异常
  * 2. 通过Core_App::dispatch()捕获的异常
  * @param  [type] $e [description]
  * @return [type]    [description]
  */
 public function handleException($e)
 {
     $controller = Core_App::getInstance()->controllerObj;
     $isBaseExp = $e instanceof Exception_Base;
     $info = array('exp' => get_class($e), 'code' => $e->getCode(), 'msg' => $e->getMessage(), 'expParams' => $isBaseExp ? $e->getParams() : null, 'line' => sprintf('%s:%d', $e->getFile(), $e->getLine()), 'uri' => Comm_Context::getServer('REQUEST_URI'), 'elapse' => sprintf('%.3f', microtime(true) - SYSTEM_START_TIME), 'reqParams' => empty($controller) ? null : $controller->getParams());
     Tool_Log::error('request exception, ' . Tool_Json::encode($info));
     if ($isBaseExp) {
         // 异常自身处理过程
         $e->handle();
     } else {
         // 默认异常处理过程
         $a = new Exception_Base();
         $a->__real__ = $e;
         $a->handle();
     }
 }
コード例 #3
0
ファイル: Abstract.php プロジェクト: 645248882/CocoPHP
 public function forward($controller, $action = 'index', $params = array())
 {
     $dispatchInfo = array('controller' => $controller, 'action' => $action, 'params' => $params);
     Core_App::getInstance()->setDispatchInfo($dispatchInfo)->setDispatched(false);
 }
コード例 #4
0
ファイル: index.php プロジェクト: hitzheng/ares
<?php

header('Content-Type: text/html; charset=utf-8');
header('Pragma: no-cache');
define('DS', DIRECTORY_SEPARATOR);
define('APP_PATH', dirname(__FILE__));
define('SYS_PATH', dirname(APP_PATH) . DS . 'system');
require SYS_PATH . '/bootstrap.php';
Core_App::getInstance()->dispatch();
コード例 #5
0
ファイル: index.php プロジェクト: 645248882/CocoPHP
<?php

define('APP_PATH', dirname(__DIR__) . '/');
define('SYS_PATH', dirname(APP_PATH) . '/System/');
require SYS_PATH . 'Core/App.php';
Core_App::getInstance()->run();
コード例 #6
0
ファイル: context.php プロジェクト: hitzheng/ares
 public static function getParam($name, $default = null)
 {
     $controllerParams = Core_App::getInstance()->controllerParams;
     return isset($controllerParams[$name]) ? $controllerParams[$name] : $default;
 }