private function _processRoute(ZRoute &$a_route, &$a_code, &$a_message) { $ctl = null; $mod = null; if ($a_route->module) { $mod = new ZModule($this, $a_route->module . 'Module'); $mod->setBaseDir($this->fromBaseDir(Zoombi::config('path.module', 'module')) . Zoombi::DS . $a_route->module); } if (!$a_route->controller) { $a_route->controller = $this->getConfig()->getValue('controller.default_name', 'index'); } if (!$a_route->action) { $a_route->action = $this->getConfig()->getValue('controller.default_action', 'index'); } if (!$mod) { $mod =& $this; } try { $ctl = $mod->load->controller($a_route->getController()); } catch (ZControllerException $e) { $a_code = $e->getCode(); $a_message = $e->getMessage(); return false; } if (!$ctl) { return false; } $this->setController($ctl); return true; }
/** * Find and load module * @param string $a_module * @return ZModule */ public final function &module($a_module) { $m = trim(strtolower($a_module)); if (isset($this->m_modules[$m]) or array_key_exists($m, $this->m_modules)) { return $this->m_modules[$m]; } $this->emit(new ZEvent($this, 'preModule', $m)); //$p = $this->getModule()->getConfig()->getValue('module.directory_name', 'module') . Zoombi::DS . $m; //$d = $this->getModule()->fromBaseDir($p); $d = $this->getModule()->fromModuleDir($m); if (!file_exists($d)) { throw new ZModuleException('Module "' . $m . '" not exist', ZControllerException::EXC_LOAD); } if (file_exists($d) and is_dir($d)) { $mod = null; try { $mod = $this->_loadClass($m, $this->m_modules, 'module', 'ZModule'); } catch (ZLoaderException $e) { switch ($e->getCode()) { case ZLoaderException::EXC_NO_FILE: $mod = new ZModule($this->getModule(), $m); $this->m_modules[$m] =& $mod; break; default: throw new ZModuleException($e->getMessage(), ZModuleException::EXC_LOAD); break; } } $mod->setBaseDir($d)->setConfig($mod->fromConfigDir('config.php'))->initialize(); $mod->setFlag('initialized'); $this->emit(new ZEvent($this, 'postModule', $m, $mod)); return $mod; } return Zoombi::$null; }