/** * @return array|false */ public static function getCallbackToDispatch(array $requestAction = array()) { $_this = GummDispatcher::getInstance(); extract($requestAction, EXTR_SKIP); if (!isset($controller)) { $controller = $_this->RequestHandler->getController(); // Render / Add to Menu the Theme Options Page if (!$controller) { return false; } if (!$controller && is_admin() && !$_this->RequestHandler->isAdminAjax()) { $controller = 'options'; $action = 'admin_index'; } elseif (!$controller) { return false; } } if (!isset($action)) { $action = $_this->RequestHandler->getAction(); } if (!$action) { $action = 'index'; if (is_admin()) { $action = 'admin_' . $action; } } // $ControllerObj = GummRegistry::get('Controller', $controller); // debug($ControllerObj); App::import('Controller', $controller); $controllerClass = Inflector::camelize($controller) . 'Controller'; if (!class_exists($controllerClass)) { trigger_error(sprintf(__('Class %s not defined.', 'gummfw'), $controllerClass), E_USER_ERROR); } $ControllerObj = new $controllerClass(); if (!is_a($ControllerObj, 'Controller')) { trigger_error(sprintf(__('Class %s must be a Controller.', 'gummfw'), $controllerClass), E_USER_ERROR); } $realAction = str_replace(GUMM_FW_PREFIX, '', $action); if (strpos($realAction, 'admin_') === false && (is_admin() || isset($_REQUEST['gummadmin']))) { $realAction = 'admin_' . $realAction; } $ControllerObj->action = $realAction; $callback = array(&$ControllerObj, $realAction); if (!is_callable($callback)) { trigger_error(__('Request is not a valid callback.', 'gummfw'), E_USER_ERROR); } return $callback; }