Changeset 11230
- Timestamp:
- 08/28/08 18:24:16 (3 months ago)
- Files:
-
- plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelColumn.class.php (modified) (3 diffs)
- plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelIndex.class.php (modified) (1 diff)
- plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelModel.class.php (modified) (3 diffs)
- plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelTable.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelColumn.class.php
r11229 r11230 170 170 * 171 171 * @see sfPropelModel 172 * 173 * @throws InvalidArgumentException If the parameter is null 172 174 */ 173 175 public function unwrap($value = null) 174 176 { 175 if ($value instanceof sfPropelTable) 176 { 177 if (is_null($value)) 178 { 179 throw new InvalidArgumentException(sprintf('%s expects a sfPropelTable object as its first parameter.', __METHOD__)); 180 } 181 elseif ($value instanceof sfPropelTable) 182 { 183 $column = clone $this->column; 184 177 185 if ($this->indexType) 178 186 { 179 $value->addIndex(sfPropelIndex::type($this->indexType)->column($ this->column));187 $value->addIndex(sfPropelIndex::type($this->indexType)->column($column)); 180 188 } 181 189 … … 185 193 $fk->setTable($value->unwrap()); 186 194 $fk->setForeignTableName($this->fkTable); 187 $fk->addReference($ this->column->getName(), $this->fkColumn);195 $fk->addReference($column->getName(), $this->fkColumn); 188 196 $fk->setOnDelete($this->fkOnDelete); 189 197 $fk->setOnUpdate($this->fkOnUpdate); … … 192 200 } 193 201 194 return $ this->column;202 return $column; 195 203 } 196 204 plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelIndex.class.php
r11229 r11230 81 81 * 82 82 * @see sfPropelModel 83 * 84 * @throws InvalidArgumentException If the parameter is null 83 85 */ 84 86 public function unwrap($value = null) 85 87 { 86 if ( $value instanceof sfPropelTable)88 if (is_null($value)) 87 89 { 90 throw new InvalidArgumentException(sprintf('%s expects a sfPropelTable object as its first parameter.', __METHOD__)); 91 } 92 elseif ($value instanceof sfPropelTable) 93 { 94 $index = clone $this->index; 95 88 96 $columns = $value->unwrap()->getColumns(); 89 97 $columns = array_combine(array_map(create_function('$c', 'return $c->getName();'), $columns), $columns); 90 91 $index = clone $this->index;92 98 93 99 foreach ($this->columns as $name) plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelModel.class.php
r11229 r11230 52 52 if (is_null($value)) 53 53 { 54 return $this->model; 54 $model = clone $this->model; 55 56 return $model; 55 57 } 56 58 … … 61 63 * @return Database 62 64 */ 63 protected function getDatabase( )65 protected function getDatabase($driver = null) 64 66 { 65 67 $database = new Database; 66 $database->setPlatform($this->getPlatform( ));68 $database->setPlatform($this->getPlatform($driver)); 67 69 68 70 return $database; … … 72 74 * @return DefaultPlatform 73 75 */ 74 protected function getPlatform( )76 protected function getPlatform($driver = null) 75 77 { 76 $class = ucwords(sfPropelBaseTask::getGeneratorConfig()->getBuildProperty('database')).'Platform'; 78 if (is_null($driver)) 79 { 80 $driver = sfPropelBaseTask::getGeneratorConfig()->getBuildProperty('database'); 81 } 82 83 $class = ucwords($driver).'Platform'; 77 84 return new $class; 78 85 } plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelTable.class.php
r11229 r11230 88 88 89 89 /** 90 * Exports the configured table as create table SQL. 91 * 92 * @param string $driver 93 * 94 * @return string 95 */ 96 public function asCreateTableSql($driver = null) 97 { 98 $table = $this->unwrap(); 99 100 $generatorConfig = sfPropelBaseTask::getGeneratorConfig(); 101 if (is_null($driver)) 102 { 103 $driver = $generatorConfig->getBuildProperty('database'); 104 } 105 else 106 { 107 $table->setDatabase($this->getDatabase($driver)); 108 } 109 110 $builderClass = ucwords($driver).'DDLBuilder'; 111 $builder = new $builderClass($table); 112 $builder->setGeneratorConfig($generatorConfig); 113 114 $script = $builder->getDatabaseStartDDL(); 115 $script .= $builder->build(); 116 $script .= $builder->getDatabaseEndDDL(); 117 118 return $script; 119 } 120 121 /** 90 122 * @see sfPropelModel 91 123 */ … … 94 126 if (is_null($value)) 95 127 { 96 $this->table->doFinalInitialization(); 97 return $this->table; 128 $table = clone $this->table; 129 $table->doFinalInitialization(); 130 131 return $table; 98 132 } 99 133