Exemple #1
0
 /**
  * Load multiple models into the Zend registry.
  *
  * @param array|string $models names of the models to load
  * @param string $module name of the module from which to load the models, defaults to core
  * @deprecated replaced by void MidasLoader::loadModels(array|string $model, string $module)
  */
 public function loadModels($models, $module = '')
 {
     MidasLoader::loadModels($models, $module);
 }
 /** Load components, forms, and models. */
 public function loadElements()
 {
     Zend_Registry::set('models', array());
     if (isset($this->_models)) {
         MidasLoader::loadModels($this->_models);
     }
     $modelsArray = Zend_Registry::get('models');
     foreach ($modelsArray as $key => $tmp) {
         $this->{$key} = $tmp;
     }
     if (isset($this->_daos)) {
         foreach ($this->_daos as $dao) {
             Zend_Loader::loadClass($dao . 'Dao', BASE_PATH . '/core/models/dao');
         }
     }
     Zend_Registry::set('components', array());
     if (isset($this->_components)) {
         foreach ($this->_components as $component) {
             $nameComponent = $component . 'Component';
             Zend_Loader::loadClass($nameComponent, BASE_PATH . '/core/controllers/components');
             if (!isset($this->Component)) {
                 $this->Component = new stdClass();
             }
             if (!class_exists($nameComponent)) {
                 throw new Zend_Exception('Unable to find ' . $nameComponent);
             }
             $this->Component->{$component} = new $nameComponent();
         }
     }
     Zend_Registry::set('forms', array());
     if (isset($this->_forms)) {
         foreach ($this->_forms as $forms) {
             $nameForm = $forms . 'Form';
             Zend_Loader::loadClass($nameForm, BASE_PATH . '/core/controllers/forms');
             if (!isset($this->Form)) {
                 $this->Form = new stdClass();
             }
             if (!class_exists($nameForm)) {
                 throw new Zend_Exception('Unable to find ' . $nameForm);
             }
             $this->Form->{$forms} = new $nameForm();
         }
     }
 }
Exemple #3
0
 /** Load model and components. */
 public function loadModuleElements()
 {
     if (isset($this->_moduleModels)) {
         MidasLoader::loadModels($this->_moduleModels, $this->moduleName);
         $modelsArray = Zend_Registry::get('models');
         foreach ($this->_moduleModels as $value) {
             if (isset($modelsArray[$this->moduleName . $value])) {
                 $tmp = ucfirst($this->moduleName) . '_' . $value;
                 $this->{$tmp} = $modelsArray[$this->moduleName . $value];
             }
         }
     }
     if (isset($this->_moduleDaos)) {
         foreach ($this->_moduleDaos as $dao) {
             if (file_exists(BASE_PATH . '/modules/' . $this->moduleName . '/models/dao/' . $dao . 'Dao.php')) {
                 include_once BASE_PATH . '/modules/' . $this->moduleName . '/models/dao/' . $dao . 'Dao.php';
             } elseif (file_exists(BASE_PATH . '/privateModules/' . $this->moduleName . '/models/dao/' . $dao . 'Dao.php')) {
                 include_once BASE_PATH . '/privateModules/' . $this->moduleName . '/models/dao/' . $dao . 'Dao.php';
             } else {
                 throw new Zend_Exception('Unable to find dao  ' . $dao);
             }
         }
     }
     if (isset($this->_moduleComponents)) {
         foreach ($this->_moduleComponents as $component) {
             $nameComponent = ucfirst($this->moduleName) . '_' . $component . 'Component';
             if (file_exists(BASE_PATH . '/modules/' . $this->moduleName . '/controllers/components/' . $component . 'Component.php')) {
                 include_once BASE_PATH . '/modules/' . $this->moduleName . '/controllers/components/' . $component . 'Component.php';
             } elseif (file_exists(BASE_PATH . '/privateModules/' . $this->moduleName . '/controllers/components/' . $component . 'Component.php')) {
                 include_once BASE_PATH . '/privateModules/' . $this->moduleName . '/controllers/components/' . $component . 'Component.php';
             } else {
                 throw new Zend_Exception('Unable to find components  ' . $component);
             }
             if (!class_exists($nameComponent)) {
                 throw new Zend_Exception('Unable to find ' . $nameComponent);
             }
             if (!isset($this->ModuleComponent)) {
                 $this->ModuleComponent = new stdClass();
             }
             $this->ModuleComponent->{$component} = new $nameComponent();
         }
     }
     if (isset($this->_moduleForms)) {
         foreach ($this->_moduleForms as $forms) {
             $nameForm = ucfirst($this->moduleName) . '_' . $forms . 'Form';
             include_once BASE_PATH . '/modules/' . $this->moduleName . '/controllers/forms/' . $forms . 'Form.php';
             if (file_exists(BASE_PATH . '/modules/' . $this->moduleName . '/controllers/forms/' . $forms . 'Form.php')) {
                 include_once BASE_PATH . '/modules/' . $this->moduleName . '/controllers/forms/' . $forms . 'Form.php';
             } elseif (file_exists(BASE_PATH . '/privateModules/' . $this->moduleName . '/controllers/forms/' . $forms . 'Form.php')) {
                 include_once BASE_PATH . '/privateModules/' . $this->moduleName . '/controllers/forms/' . $forms . 'Form.php';
             } else {
                 throw new Zend_Exception('Unable to find form  ' . $forms);
             }
             if (!class_exists($nameForm)) {
                 throw new Zend_Exception('Unable to find ' . $nameForm);
             }
             if (!isset($this->ModuleForm)) {
                 $this->ModuleForm = new stdClass();
             }
             $this->ModuleForm->{$forms} = new $nameForm();
         }
     }
 }