static function perform_controller_action($class_path, $action, $objects, $parameters) { //We treat 'new' the same as 'edit', since they generally contain a lot of the same code if ($action == "new") { $action = "edit"; } //Let's look for a controller $controller_path = SITE_PATH . "/controllers/" . $class_path . "_controller.php"; if (file_exists($controller_path)) { require_once $controller_path; $class_path_components = explode("/", $class_path); $class = $class_path_components[count($class_path_components) - 1]; $controller_class = $class . "_controller"; if (!method_exists($controller_class, $action)) { if (router::render_view($class_path, $action)) { exit; } else { fatal_error("{$controller_class} does not respond to {$action}"); } } $controller = new $controller_class(); $controller->parameters = $parameters; call_user_func_array(array($controller, $action), $objects); exit; } //If no controller was found, we'll look for a view if (router::render_view($class_path, $action)) { exit; } }