public static function run() { global $app_state; global $app_controller; $route = \reasg\router::loadFromRequest(); self::$route = $route; reasg_dev_dump($_REQUEST, '$_REQUEST'); reasg_dev_dump($route, '$route'); $app_controller->dispatchEvent("app_init_with_route", [$route]); //print "ROOT=" . REASG_ROOT_PATH . "\n"; //print "ENGINE=" . REASG_ENGINE_PATH . "\n"; //print "ENGINE_JS=" . REASG_ENGINE_JS_PATH . "\n"; if (isset($route['controller']) && isset($route['scope'])) { $p = REASG_ROOT_PATH . $route['scope'] . '/' . $route['controller'] . '.controller.php'; if (!file_exists($p)) { ///TODO: error handler return; } self::$path = REASG_ROOT_PATH . $route['scope'] . '/'; define('REASG_SELF_DIRECTORY', self::$path); define('REASG_SELF_PATH', $p); include_once $p; $frs = '\\' . $route['scope'] . '\\' . $route['controller']; define('REASG_SELF_LOCATION', $route['location']); define('REASG_SELF_SCOPE', $route['scope']); define('REASG_SELF_CONTROLLER', $route['controller']); define('REASG_SELF_CONTROLLER_ACTION', $route['action']); define('REASG_SELF_CONTROLLER_CLASS', $frs); define('REASG_SELF_URL', ''); ///TODO how to do this nice! $app_controller->dispatchEvent("app_init_controller", [$frs]); $a = new $frs(); $a->scope = $route['scope']; $a->location = $route['location']; $a->controller = $app_controller; if (method_exists($a, 'initialize')) { call_user_func([$a, 'initialize'], $route['values']); } $app_controller->dispatchEvent("app_start", $route); if (method_exists($a, $route['action'])) { call_user_func([$a, $route['action']], $route['values']); } elseif (method_exists($a, 'main')) { call_user_func([$a, 'main'], $route['values']); } if (!$app_state['ended']) { $app_controller->commit(); $app_controller->end(); } } }
public function delegateFor($name) { if (!method_exists($this, $name)) { return function () { }; } $obj = $this; $method = $name; $fnc = function () use($obj, $method) { $args = func_get_args(); reasg_dev_dump($args[0]); call_user_func_array([$obj, $method], $args); }; $fnc->bindTo($this, $this); return $fnc; }
public function debug() { error_log("current_field=" . $this->current_field); reasg_dev_dump($this->fields[$this->current_field], "current_field"); }