/** * Método que arranca la aplicación * @return void */ public function run() { // se establece la codificación de funciones, entradas y salidas mb_internal_encoding('UTF-8'); mb_http_output('UTF-8'); mb_http_input('UTF-8'); mb_language('uni'); mb_regex_encoding('UTF-8'); // se establece el gestor de errores $this->error->setHandler(true); // se establecen comportamientos según el ambiente de la aplicación if ($this->config['tornado_environment_development'] === true) { ini_set('display_errors', '1'); error_reporting(E_ALL); if ($this->config['tornado_environment_development'] === true) { $this->annotation->findRoutes($this->config['tornado_hmvc_module_path'], $this->config['tornado_hmvc_serialize_path']); } } else { ini_set('display_errors', '0'); error_reporting(0); } // si se usan módulos HMVC if ($this->config['tornado_hmvc_module_path']) { // se registran las rutas serializadas de los controladores $this->router->unserialize($this->config['tornado_hmvc_serialize_path']); // se registra el path de los módulos $this->router->setPathModules($this->config['tornado_hmvc_module_path']); } // flujo de ejecución: // - se ejecutan los hooks init // - se parsea la url en busca de la ruta a ejecutar // - - si no hay coincidencias se ejecuta: // - - - hooks 404 // - - - hooks end // - - - se finaliza // - se ejecutan los hooks before // - - si alguno devuelve false se ejecuta: // - - - hooks end // - - - se finaliza // - se ejecuta la ruta // - se ejecutan los hooks after // - se ejecutan los hooks end $this->hook->call('init'); $flowReturn = $this->router->parseUrl(); if ($flowReturn === false) { $this->hook->call('404'); $this->finishRequest(); $this->hook->call('end'); return; } $flowReturn = $this->hook->call('before'); if ($flowReturn === false) { $this->finishRequest(); $this->hook->call('end'); return; } $this->router->execute(); $this->hook->call('after'); $this->finishRequest(); $this->hook->call('end'); }