/** * Generate a set of models for the schema information source * * @param string $prefix Prefix to generate the models with * @param mixed $item The item to generate the models from * @return string $path The path where the models were generated * @throws Doctrine_Migration_Exception $e */ protected function _generateModels($prefix, $item) { $path = $this->_tmpPath . DIRECTORY_SEPARATOR . strtolower($prefix) . '_doctrine_tmp_dirs'; $options = array('classPrefix' => $prefix, 'generateBaseClasses' => false); if (is_string($item) && file_exists($item)) { $extension = $this->_getItemExtension($item); if ($extension === 'yml') { Doctrine_Core::generateModelsFromYaml($item, $path, $options); return $path; } else { if ($extension === 'php') { Doctrine_Lib::copyDirectory($item, $path); return $path; } else { throw new Doctrine_Migration_Exception('No php or yml files found at path: "' . $item . '"'); } } } else { try { Doctrine_Core::generateModelsFromDb($path, (array) $item, $options); return $path; } catch (Exception $e) { throw new Doctrine_Migration_Exception('Could not generate models from connection: ' . $e->getMessage()); } } }
/** * Generate a set of models for the schema information source * * @param string $prefix Prefix to generate the models with * @param mixed $item The item to generate the models from * @return string $path The path where the models were generated * @throws Doctrine_Migration_Exception $e */ protected function _generateModels($prefix, $item) { $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . strtolower($prefix) . '_doctrine_tmp_dirs'; $options = array('classPrefix' => $prefix); if (is_string($item) && file_exists($item)) { if (is_dir($item)) { $files = glob($item . DIRECTORY_SEPARATOR . '*.*'); } else { $files = array($item); } if (isset($files[0])) { $pathInfo = pathinfo($files[0]); $extension = $pathInfo['extension']; } if ($extension === 'yml') { Doctrine::generateModelsFromYaml($item, $path, $options); return $path; } else { if ($extension === 'php') { Doctrine_Lib::copyDirectory($item, $path); return $path; } else { throw new Doctrine_Migration_Exception('No php or yml files found at path: "' . $item . '"'); } } } else { try { Doctrine::generateModelsFromDb($path, (array) $item, $options); return $path; } catch (Exception $e) { throw new Doctrine_Migration_Exception('Could not generate models from connection: ' . $e->getMessage()); } } }