_mvcParams[$name] = $value; return $this; } /** * Ajout des paramètres * * @param array $parametres * * @return mixed objet utilisant le trait */ public function setParams(array $parametres) { $this->_mvcParams = array_merge($this->_mvcParams, $parametres); return $this; } /** * Récupère un paramètre * * @param string $name * * @return mixed valeur du parametre ou NULL */ public function getParam($name) { if (isset($this->_mvcParams[$name])) { return $this->_mvcParams[$name]; } return null; } /** * Récupère tous les paramètres * * @return array */ public function getParams() { return $this->_mvcParams; } /** * Distribue la requête HTTP à un couple controleur/action * * @return Response */ public function run() { /* * Initialise les composants */ //---- initialise l'objet requête $this->getRequest(true) ->setBaseUrl(\Mvc\Application::getBaseUrl()); //---- initialise l'objet routeur $this->_router = new Router(); //---- initialise l'objet réponse $this->getResponse(true); //---- initialise l'objet distributeur $this->_dispatcher = new Dispatcher(); $this->_dispatcher->setResponse($this->_response); /* * Distribue */ //---- effectue le routage $this->_router->route($this->_request); try { //---- distribue la requête $this->_dispatcher->dispatch($this->_request, $this->_response); } catch (Exception $e) { echo $e; } //---- envoi la réponse HTTP $this->_response->send(); } }