コード例 #1
0
ファイル: Abstract.php プロジェクト: BGCX262/zym-svn-to-git
 /**
  * Load the model
  * 
  * @throws Exception
  * @param string $modelName
  * @param string $module
  * @param string $modelPrefix
  */
 public function loadModel($modelName, $module = null, $modelPrefix = null)
 {
     $modelName = ucfirst($modelName);
     $fileName = $modelName . '.php';
     if (!$module) {
         $module = $this->_request->getModuleName();
     }
     if (!$modelPrefix) {
         $modelPrefix = $this->_modelPrefix;
     }
     if ($modelPrefix) {
         $modelName = ucfirst($modelPrefix) . '_' . $modelName;
     }
     $modelName = str_ireplace('_', '/', $modelName);
     if (class_exists($modelName, false)) {
         return true;
     }
     $controllerDirectory = $this->_dispatcher->getControllerDirectory($module);
     $moduleDirectory = dirname($controllerDirectory);
     $modelDirectory = $moduleDirectory . '/' . $this->_modelDirectory;
     Zend_Loader::loadFile($fileName, $modelDirectory, true);
     if (!class_exists($modelName, false)) {
         throw new Zym_Loader_Exception('Failed to load class "' . $modelName . '"');
     }
     return true;
 }
コード例 #2
0
 public function getControllerDirectory($module = null)
 {
     if ($module == 'component' || $module == 'component_test') {
         return '';
     } else {
         return parent::getControllerDirectory($module);
     }
 }
コード例 #3
0
ファイル: Abstract.php プロジェクト: BGCX262/zym-svn-to-git
 /**
  * Load the model
  *
  * @throws Exception
  * @param string $modelName
  * @param string $modelPrefix
  * @param string $module
  */
 public function loadModel($modelName, $modelPrefix = null, $module = null)
 {
     $modelName = ucfirst($modelName);
     if (!$module) {
         $module = $this->_request->getModuleName();
     }
     if (!$modelPrefix) {
         $modelPrefix = $this->_modelPrefix;
     }
     if ($modelPrefix) {
         $modelName = ucfirst($modelPrefix) . '/' . $modelName;
     }
     $modelName = str_ireplace('_', '/', $modelName);
     $controllerDirectory = $this->_dispatcher->getControllerDirectory($module);
     $moduleDirectory = dirname($controllerDirectory);
     $filePath = array($moduleDirectory, $this->_modelDirectory, $modelName);
     $file = implode('/', $filePath) . '.php';
     if (file_exists($file)) {
         require_once $file;
     } else {
         throw new Exception(sprintf('File "%s" could not be loaded', $file));
     }
 }