/** * Dispatch * @param $action */ private function dispatch($action) { if ($this->blockLoad) { return; } if (empty($action)) { $action = $this->contollerDefault . "/" . $this->actionDefault; } $app_action = $this->getAction($action); if (is_numeric($app_action->action)) { $app_action->params[] = $app_action->action; $app_action->action = $this->actionDefault; } $controller = $app_action->controller_class; if ($this->configuration->useMVCAppController()) { App::loadController('AppController'); } if ($this->configuration->useMVCAppModel()) { App::loadModel('AppModel'); } if (App::loadController($controller)) { $suffix_action = $this->configuration->getMVCSuffixAction(); $action_method = $app_action->action . $suffix_action; $attributes = ["template" => $this->configuration->getMVCTemplate()]; $dispatch = new $controller($app_action->controller, $app_action->action, $attributes); $this->executeController($dispatch, $action_method, $app_action->params); } else { $this->executeError(); } }
/** * Carrega as models * @param string, [...] $model nome da model */ public function loadModel($model) { $models = func_get_args(); foreach ($models as $model) { $class_model = $model . 'Model'; if (App::loadModel($class_model)) { $this->models->{$model} = new $class_model(); } } }