Go to the documentation of this file.00001 <?php
00011 final class nyro {
00012
00018 private static $cfg;
00019
00023 private function __construct() {}
00024
00028 private static function init() {
00029 if (!self::$cfg) {
00030 factory::init();
00031 if (DEV) {
00032 debug::timer('nyro');
00033 debug::timer('nyroProcess');
00034 }
00035 request::init();
00036 self::$cfg = new config(factory::loadCfg(__CLASS__));
00037 file::init();
00038 session::initFlash();
00039 }
00040 }
00041
00045 public static function main() {
00046
00047 define('NYROVERSION', '0.2');
00048
00049 try {
00050 self::init();
00051
00052 $resp = response::getInstance();
00053 self::$cfg->overload(__CLASS__.'Response');
00054
00055 request::execModule();
00056
00057 if (DEV) {
00058 debug::timer('nyroProcess');
00059 debug::timer('nyroRender');
00060 }
00061
00062 $resp->setContent(request::publishModule());
00063 } catch (module_exception $e) {
00064 session::setFlash('nyroError', 'MODULE or ACTION NOT FOUND<br />'.self::handleError($e));
00065 $resp->error(null, 404);
00066 } catch (nException $e) {
00067 session::setFlash('nyroError', self::handleError($e));
00068 $resp->error(null, 500);
00069 } catch (PDOException $e) {
00070 session::setFlash('nyroError', self::handleError($e));
00071 $resp->error(null, 500);
00072 } catch (Exception $e) {
00073 session::setFlash('nyroError', self::handleError($e));
00074 $resp->error(null, 500);
00075 }
00076
00077 try {
00078 factory::saveCache();
00079
00080 echo $resp->send();
00081 } catch (Exception $e) {
00082 echo debug::trace($e);
00083 }
00084 }
00085
00092 public static function getGlobalCfg($name) {
00093 if (self::$cfg && self::$cfg->check($name))
00094 return self::$cfg->get($name);
00095 return array();
00096 }
00097
00103 public static function getCfg() {
00104 return self::$cfg;
00105 }
00106
00113 private static function handleError(Exception $err) {
00114 return debug::trace($err, DEV? 2 : 0);
00115 }
00116
00117 }