Example #1
0
 /**
  * Find and load module
  * @param string $a_module
  * @return Zoombi_Module
  */
 public final function module($a_module, $a_throw = false)
 {
     $mod_name = trim(strtolower($a_module));
     if (isset($this->m_modules[$mod_name]) or array_key_exists($mod_name, $this->m_modules)) {
         return $this->m_modules[$mod_name];
     }
     $this->emit(new Zoombi_Event($this, 'preModule', $mod_name));
     $mod_dir = $this->getModule()->fromModuleDir($mod_name);
     if (!file_exists($mod_dir)) {
         if ($a_throw) {
             throw new Zoombi_Exception_Module('Module "' . $mod_name . '" not exist', Zoombi_Exception_Controller::EXC_LOAD);
         }
     } else {
         $module = false;
         try {
             $module = $this->_loadClass($mod_name, $this->m_modules, 'module', 'Zoombi_Module');
         } catch (Zoombi_Exception_Loader $e) {
             if ($a_throw) {
                 throw new Zoombi_Exception_Module($e->getMessage(), Zoombi_Exception_Module::EXC_LOAD);
             }
             $module = new Zoombi_Module($this->getModule(), $mod_name);
             $this->m_modules[$mod_name] = $module;
         }
         $module->initialize();
         $module->setFlag('initialized');
         $this->emit(new Zoombi_Event($this, 'postModule', $mod_name, $module));
         return $module;
     }
     return false;
 }
 /**
  * Not exist function calls
  * @param string $a_name
  * @param array $a_params
  */
 public function __call($a_name, $a_params)
 {
     switch ($a_name) {
         case 'run':
         case 'exec':
         case 'start':
         case 'render':
         case 'display':
             if (!$this->getFlag(self::FLAG_NO_EXECUTE)) {
                 return $this->execute();
             }
     }
     return parent::__call($a_name, $a_params);
 }