public function addComponent($name, $options = array()) { $class = InflectionComponent::camelCase($name) . 'Component'; $this->Components[$name] = new $class($this, $options); }
public function dispatch() { $class = InflectionComponent::camelCase($this->controller) . 'Controller'; $action = InflectionComponent::camelCase($this->action, false); if (!class_exists($class)) { throw new Except("Le Controlleur '" . $class . "' n'existe pas", 404); } if (!method_exists($class, $action)) { throw new Except("L'Action '" . $action . "' n'existe pas dans " . $class, 404); } $get = Request::getInstance()->get(); $post = Request::getInstance()->post(); $Controller = new $class($action); $Controller->app = $this->app; foreach ($this->params as $key => $value) { $Controller->setParam($key, $value); } foreach ($get as $key => $value) { $Controller->setParam($key, $value); } foreach ($post as $key => $value) { $Controller->setParam($key, $value); } $Controller->preExecute(); call_user_func_array(array($Controller, $action), $this->rawParams); $Controller->postExecute(); $Controller->spit(); }