Пример #1
0
 /**
  * load module by keyname
  *
  * @param type $keyname
  */
 protected function loadModule($keyname)
 {
     try {
         // define modulePath
         $modulePath = PROJECT_PATH . '/module/' . $keyname;
         // define moduleFile name
         $moduleFile = $modulePath . '/Module.php';
         // define moduleFile class
         $moduleFileClass = ucfirst($keyname) . 'Module';
         // include module file
         include_once $moduleFile;
         // init module file
         $module = new $moduleFileClass();
         // get modul config
         $moduleConfig = new Zend_Config_Ini($module->getConfigPath());
         // save config
         Knowledgeroot_Registry::set($keyname . '_config', $moduleConfig);
         // check if autoloader should include module lib path
         if ($moduleConfig->module->lib->path) {
             // add module lib to include path
             set_include_path(implode(PATH_SEPARATOR, array(realpath($modulePath . '/' . $moduleConfig->module->lib->path), get_include_path())));
             // check namespace
             if ($moduleConfig->module->namespace) {
                 $namespace = $moduleConfig->module->namespace;
             } else {
                 $namespace = $moduleFileClass . '_';
             }
             // add module prefix to autoloader
             $autoloader = Knowledgeroot_Registry::get('loader');
             $autoloader->registerNamespace($namespace);
         }
         // check for bootstrap
         if ($moduleConfig->module->bootstrap->path && $moduleConfig->module->bootstrap->class) {
             // get bootstrap
             $bootstrapPath = $modulePath . '/' . $moduleConfig->module->bootstrap->path;
             $boostrapClass = $moduleConfig->module->bootstrap->class;
             // include bootstrap class
             include_once $bootstrapPath;
             // init bootstrap
             $bootstrap = new $boostrapClass();
             $bootstrap->run();
         }
     } catch (Exception $e) {
         throw new Knowledgeroot_ModuleManager_Exception('Could not load Module: ' . $keyname, 0, $e);
     }
 }
Пример #2
0
 /**
  * init modules
  */
 protected function _initModules()
 {
     try {
         // load config
         $this->bootstrap('config');
         // init module manager
         $manager = new Knowledgeroot_ModuleManager();
         // load modules
         $manager->loadModules();
         // save filemanager
         Knowledgeroot_Registry::set('modulemanager', $manager);
     } catch (Exception $e) {
         echo $e->getMessage();
         die('could not load modules');
     }
 }