Changeset 3847
- Timestamp:
- 02/19/08 23:30:54 (17 months ago)
- Location:
- branches/0.10
- Files:
-
- 7 modified
-
lib/Doctrine.php (modified) (2 diffs)
-
lib/Doctrine/Export.php (modified) (3 diffs)
-
lib/Doctrine/Export/Schema.php (modified) (2 diffs)
-
lib/Doctrine/Migration.php (modified) (2 diffs)
-
lib/Doctrine/Migration/Builder.php (modified) (3 diffs)
-
tools/sandbox/config.php.dist (modified) (1 diff)
-
tools/sandbox/index.php.dist (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine.php
r3834 r3847 566 566 if ($foundClasses) { 567 567 foreach ($foundClasses as $className) { 568 if (self::isValidModelClass($className) && !in_array($className, $loadedModels)) {568 if (self::isValidModelClass($className)) { 569 569 $loadedModels[] = $className; 570 570 571 self::$_loadedModelFiles[$className] = $file->getPathName(); 571 572 self::$_pathModels[$file->getPathName()][$className] = $className; 572 573 } … … 579 580 } 580 581 581 // We do not want to filter invalid models when using conservative model loading 582 // The filtering requires that the class be loaded and inflected in order to determine if it is 583 // a valid class. 584 if ($manager->getAttribute(Doctrine::ATTR_MODEL_LOADING) == Doctrine::MODEL_LOADING_CONSERVATIVE) { 585 return $loadedModels; 586 } else { 587 return self::filterInvalidModels($loadedModels); 588 } 582 return $loadedModels; 589 583 } 590 584 -
branches/0.10/lib/Doctrine/Export.php
r3844 r3847 1042 1042 { 1043 1043 if ($directory !== null) { 1044 $models = Doctrine:: loadModels($directory);1044 $models = Doctrine::filterInvalidModels(Doctrine::loadModels($directory)); 1045 1045 } else { 1046 1046 $models = Doctrine::getLoadedModels(); 1047 1047 } 1048 1048 1049 1049 $this->exportClasses($models); 1050 1050 } … … 1060 1060 */ 1061 1061 public function exportClasses(array $classes) 1062 { 1062 { 1063 1063 $connections = array(); 1064 1064 foreach ($classes as $class) { 1065 $record = new $class(); 1066 $connection = $record->getTable()->getConnection(); 1067 $connectionName = Doctrine_Manager::getInstance()->getConnectionName($connection); 1065 $connection = Doctrine_Manager::getInstance()->getConnectionForComponent($class); 1066 $connectionName = $connection->getName(); 1068 1067 1069 1068 if ( ! isset($connections[$connectionName])) { … … 1246 1245 { 1247 1246 if ($directory !== null) { 1248 $models = Doctrine:: loadModels($directory);1247 $models = Doctrine::filterInvalidModels(Doctrine::loadModels($directory)); 1249 1248 } else { 1250 1249 $models = Doctrine::getLoadedModels(); -
branches/0.10/lib/Doctrine/Export/Schema.php
r3844 r3847 45 45 public function buildSchema($directory = null, $models = array()) 46 46 { 47 if ($directory ) {48 $loadedModels = Doctrine:: loadModels($directory);47 if ($directory !== null) { 48 $loadedModels = Doctrine::filterInvalidModels(Doctrine::loadModels($directory)); 49 49 } else { 50 50 $loadedModels = Doctrine::getLoadedModels(); 51 51 } 52 52 53 53 $array = array(); 54 54 … … 65 65 } 66 66 67 $record = new $className(); 68 $recordTable = $record->getTable(); 67 $recordTable = Doctrine::getTable($className); 69 68 70 69 $data = $recordTable->getExportableFormat(); -
branches/0.10/lib/Doctrine/Migration.php
r3820 r3847 123 123 * @return void 124 124 */ 125 public function loadMigrationClassesFromDirectory($classes){ 125 public function loadMigrationClassesFromDirectory() 126 { 127 $classes = get_declared_classes(); 128 126 129 foreach ((array) $this->_migrationClassesDirectory as $dir) { 127 130 $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), … … 155 158 protected function loadMigrationClasses() 156 159 { 157 if ($this->_migrationClasses) {158 return $this->_migrationClasses;159 }160 161 $classes = get_declared_classes();162 163 160 if ($this->_migrationClassesDirectory !== null) { 164 $this->loadMigrationClassesFromDirectory($classes); 165 } 166 161 $this->loadMigrationClassesFromDirectory(); 162 } 167 163 168 164 $parent = new ReflectionClass('Doctrine_Migration'); -
branches/0.10/lib/Doctrine/Migration/Builder.php
r3844 r3847 156 156 public function generateMigrationsFromModels($modelsPath = null) 157 157 { 158 if ($modelsPath ) {159 $models = Doctrine:: loadModels($modelsPath);158 if ($modelsPath !== null) { 159 $models = Doctrine::filterInvalidModels(Doctrine::loadModels($modelsPath)); 160 160 } else { 161 161 $models = Doctrine::getLoadedModels(); … … 173 173 174 174 $className = 'Add' . Doctrine::classify($export['tableName']); 175 175 176 176 $this->generateMigrationClass($className, array(), $up, $down); 177 177 } 178 178 179 $className = 'ApplyForeignKeyConstraints'; 180 181 $up = ''; 182 $down = ''; 183 foreach ($foreignKeys as $tableName => $definitions) { 184 $tableForeignKeyNames[$tableName] = array(); 185 186 foreach ($definitions as $definition) { 187 $definition['name'] = $tableName . '_' . $definition['foreignTable'] . '_' . $definition['local'] . '_' . $definition['foreign']; 179 if ( ! empty($foreignKeys)) { 180 $className = 'ApplyForeignKeyConstraints'; 181 182 $up = ''; 183 $down = ''; 184 foreach ($foreignKeys as $tableName => $definitions) { 185 $tableForeignKeyNames[$tableName] = array(); 186 187 foreach ($definitions as $definition) { 188 $definition['name'] = $tableName . '_' . $definition['foreignTable'] . '_' . $definition['local'] . '_' . $definition['foreign']; 188 189 189 $up .= $this->buildCreateForeignKey($tableName, $definition); 190 $down .= $this->buildDropForeignKey($tableName, $definition); 190 $up .= $this->buildCreateForeignKey($tableName, $definition); 191 $down .= $this->buildDropForeignKey($tableName, $definition); 192 } 191 193 } 192 }193 194 $this->generateMigrationClass($className, array(), $up, $down);194 195 $this->generateMigrationClass($className, array(), $up, $down); 196 } 195 197 196 198 return true; … … 274 276 $path = $this->getMigrationsPath() . DIRECTORY_SEPARATOR . $fileName; 275 277 278 if ( class_exists($className)) { 279 throw new Doctrine_Exception('Migration class with the name "' . $className . '" already exists.'); 280 } 281 276 282 file_put_contents($path, $class); 277 283 } -
branches/0.10/tools/sandbox/config.php.dist
r3797 r3847 52 52 53 53 Doctrine_Manager::getInstance()->setAttribute('model_loading', 'conservative'); 54 55 Doctrine::loadModels('models'); -
branches/0.10/tools/sandbox/index.php.dist
r2859 r3847 1 1 <?php 2 2 require_once('config.php'); 3 4 Doctrine::loadModels('models');