|
|
|
@ -133,12 +133,15 @@ |
|
|
|
try { |
|
|
|
try { |
|
|
|
$this->applyHook('app.before', $this); |
|
|
|
$this->applyHook('app.before', $this); |
|
|
|
ob_start(); |
|
|
|
ob_start(); |
|
|
|
$this->applyHook('app.before.router', $this); |
|
|
|
|
|
|
|
$httpMethod = $this->request->getMethod(); |
|
|
|
$httpMethod = $this->request->getMethod(); |
|
|
|
$uri = rtrim($this->request->getResourceUri(), "/"); |
|
|
|
$uri = rtrim($this->request->getResourceUri(), "/"); |
|
|
|
if ($uri == '') $uri = '/index'; |
|
|
|
if ($uri == '') $uri = '/index'; |
|
|
|
$controller_name = $this->config('controller_path') . $uri . "_controller.php"; |
|
|
|
$controller_name = $this->config('controller_path') . $uri . "_controller.php"; |
|
|
|
$controller_class_name = substr($uri, strrpos($uri, '/') + 1) . "Controller"; |
|
|
|
$controller_class_name = substr($uri, strrpos($uri, '/') + 1) . "Controller"; |
|
|
|
|
|
|
|
$controller_class_name = str_replace('.', '_', $controller_class_name); |
|
|
|
|
|
|
|
$hook_responce = $this->applyHook('app.before.router', array($this, $controller_name, $controller_class_name)); |
|
|
|
|
|
|
|
$controller_name = $hook_responce[1]; |
|
|
|
|
|
|
|
$controller_class_name = $hook_responce[2]; |
|
|
|
if (file_exists($controller_name)) { |
|
|
|
if (file_exists($controller_name)) { |
|
|
|
include ($controller_name); |
|
|
|
include ($controller_name); |
|
|
|
//создать экземпляр класса и проверить поддерживается ли http метод, если нет - ошибка 405 |
|
|
|
//создать экземпляр класса и проверить поддерживается ли http метод, если нет - ошибка 405 |
|
|
|
@ -336,17 +339,17 @@ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get application Log (lazy-loaded) |
|
|
|
* Get application Log (lazy-loaded) |
|
|
|
* @return Slim_Log |
|
|
|
* @return Harmonious_Log |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getLog() { |
|
|
|
public function getLog() { |
|
|
|
if ( !isset($this->log) ) { |
|
|
|
if ( !isset($this->log) ) { |
|
|
|
$this->log = new Slim_Log(); |
|
|
|
$this->log = new Harmonious_Log(); |
|
|
|
$this->log->setEnabled($this->config('log.enable')); |
|
|
|
$this->log->setEnabled($this->config('log.enable')); |
|
|
|
$logger = $this->config('log.logger'); |
|
|
|
$logger = $this->config('log.logger'); |
|
|
|
if ( $logger ) { |
|
|
|
if ( $logger ) { |
|
|
|
$this->log->setLogger($logger); |
|
|
|
$this->log->setLogger($logger); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->log->setLogger(new Slim_Logger($this->config('log.path'), $this->config('log.level'))); |
|
|
|
$this->log->setLogger(new Harmonious_Logger($this->config('log.path'), $this->config('log.level'))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return $this->log; |
|
|
|
return $this->log; |
|
|
|
@ -706,7 +709,8 @@ |
|
|
|
foreach( $this->hooks[$name] as $priority ) { |
|
|
|
foreach( $this->hooks[$name] as $priority ) { |
|
|
|
if( !empty($priority) ) { |
|
|
|
if( !empty($priority) ) { |
|
|
|
foreach($priority as $callable) { |
|
|
|
foreach($priority as $callable) { |
|
|
|
$hookArg = call_user_func($callable, $hookArg); |
|
|
|
if (is_array($hookArg)) $hookArg = call_user_func_array($callable, $hookArg); |
|
|
|
|
|
|
|
else $hookArg = call_user_func($callable, $hookArg); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -770,6 +774,8 @@ |
|
|
|
* @throws ErrorException |
|
|
|
* @throws ErrorException |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function handleErrors( $errno, $errstr = '', $errfile = '', $errline = '' ) { |
|
|
|
public static function handleErrors( $errno, $errstr = '', $errfile = '', $errline = '' ) { |
|
|
|
|
|
|
|
if (isset($this)) $this->getLog()->error('handleErrors catched: '.$errstr); |
|
|
|
|
|
|
|
|
|
|
|
if ( error_reporting() & $errno ) { |
|
|
|
if ( error_reporting() & $errno ) { |
|
|
|
if (isset($this)) $this->getLog()->error('Unhandled Error: '.$errstr); |
|
|
|
if (isset($this)) $this->getLog()->error('Unhandled Error: '.$errstr); |
|
|
|
throw new ErrorException($errstr, $errno, 0, $errfile, $errline); |
|
|
|
throw new ErrorException($errstr, $errno, 0, $errfile, $errline); |
|
|
|
|