protected static function dispatch_target(target $target) { try { visitor::set_target($target); visitor::restore_roles(); list($controller_name, $action_name) = $target->get_target_pair(); $controller = $controller_name . '_controller'; $controller_file = controller_dir . '/'; if ($target->has_module()) { $controller_file .= $target->get_module_name() . '/'; } $controller_file .= $controller . '.php'; if (!is_readable($controller_file)) { throw new visitor_except('controller "' . $controller_name . '" does not exist', 404); } loader::load_file($controller_file); $action = $action_name . '_action'; if (!is_callable([$controller, $action], false)) { throw new visitor_except('action "' . $action_name . '" does not exist', 404); } self::run_action($controller_name, $controller, $action, null, true); } catch (\Exception $e) { self::dispatch_except($e); } }