Changeset 3887
- Timestamp:
- 02/22/08 20:59:43 (17 months ago)
- Location:
- branches/0.10/lib
- Files:
-
- 3 modified
-
Doctrine.php (modified) (4 diffs)
-
Doctrine/Import/Builder.php (modified) (1 diff)
-
Doctrine/Migration/Builder.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine.php
r3884 r3887 535 535 * Recursively load all models from a directory or array of directories 536 536 * 537 * @param string $directory Path to directory of models or array of directory paths 538 * @return array $loadedModels 539 */ 540 public static function loadModels($directory) 541 { 537 * @param string $directory Path to directory of models or array of directory paths 538 * @param integer $forceStyle Pass value of Doctrine::ATTR_MODEL_LOADING to force a certain style of model loading 539 * Allowed Doctrine::MODEL_LOADING_AGGRESSIVE(default) or Doctrine::MODEL_LOADING_CONSERVATIVE 540 * @return array $modelLoading Array of the models loaded by the operation 541 */ 542 public static function loadModels($directory, $modelLoading = null) 543 { 544 $manager = Doctrine_Manager::getInstance(); 545 546 $modelLoading = $modelLoading === null ? $manager->getAttribute(Doctrine::ATTR_MODEL_LOADING):$modelLoading; 547 542 548 $loadedModels = array(); 543 549 544 if ($directory !== null) { 545 $manager = Doctrine_Manager::getInstance(); 546 550 if ($directory !== null && is_dir($directory)) { 547 551 foreach ((array) $directory as $dir) { 548 552 $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), … … 552 556 if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) { 553 557 554 if ($m anager->getAttribute(Doctrine::ATTR_MODEL_LOADING)== Doctrine::MODEL_LOADING_CONSERVATIVE) {558 if ($modelLoading == Doctrine::MODEL_LOADING_CONSERVATIVE) { 555 559 self::$_loadedModelFiles[$e[0]] = $file->getPathName(); 556 560 self::$_pathModels[$file->getPathName()][$e[0]] = $e[0]; … … 578 582 } 579 583 } 584 } else { 585 throw new Doctrine_Exception('You must pass a valid path to a directory containing Doctrine models'); 580 586 } 581 587 … … 914 920 * generateMigrationsFromModels 915 921 * 916 * @param string $migrationsPath 917 * @param string $modelsPath 918 * @return void 919 */ 920 public static function generateMigrationsFromModels($migrationsPath, $modelsPath = null) 922 * @param string $migrationsPath Path to your Doctrine migration classes 923 * @param string $modelsPath Path to your Doctrine model classes 924 * @param integer $modelLoading Style of model loading to use for loading the models in order to generate migrations 925 * @return void 926 */ 927 public static function generateMigrationsFromModels($migrationsPath, $modelsPath = null, $modelLoading = null) 921 928 { 922 929 $builder = new Doctrine_Migration_Builder($migrationsPath); 923 930 924 return $builder->generateMigrationsFromModels($modelsPath );931 return $builder->generateMigrationsFromModels($modelsPath, $modelLoading); 925 932 } 926 933 -
branches/0.10/lib/Doctrine/Import/Builder.php
r3884 r3887 790 790 791 791 if (isset($definition['generate_once']) && $definition['generate_once'] === true) { 792 if ( !file_exists($writePath)) {792 if ( ! file_exists($writePath)) { 793 793 $bytes = file_put_contents($writePath, $code); 794 794 } -
branches/0.10/lib/Doctrine/Migration/Builder.php
r3884 r3887 141 141 Doctrine::generateModelsFromDb($directory); 142 142 143 $result = $this->generateMigrationsFromModels($directory );143 $result = $this->generateMigrationsFromModels($directory, Doctrine::MODEL_LOADING_CONSERVATIVE); 144 144 145 145 Doctrine_Lib::removeDirectories($directory); … … 154 154 * @return void 155 155 */ 156 public function generateMigrationsFromModels($modelsPath = null )156 public function generateMigrationsFromModels($modelsPath = null, $modelLoading = null) 157 157 { 158 158 if ($modelsPath !== null) { 159 $models = Doctrine::filterInvalidModels(Doctrine::loadModels($modelsPath ));159 $models = Doctrine::filterInvalidModels(Doctrine::loadModels($modelsPath, $modelLoading)); 160 160 } else { 161 161 $models = Doctrine::getLoadedModels();