Changeset 8815
- Timestamp:
- 05/06/08 19:59:18 (5 months ago)
- Files:
-
- branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelDatabaseSchema.class.php (modified) (4 diffs)
- branches/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/new_schema.yml (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.xml (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.yml (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/test/unit/sfPropelDatabaseSchemaTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelDatabaseSchema.class.php
r7928 r8815 117 117 $classes[$phpName]['behaviors'] = $column_params; 118 118 break; 119 case '_inheritance': 120 $classes[$phpName]['inheritance'] = $column_params; 121 break; 119 122 case '_foreignKeys': 120 123 $classes[$phpName]['foreignKeys'] = $column_params; … … 192 195 } 193 196 197 // Inheritance 198 if (isset($classParams['inheritance'])) 199 { 200 $tableParams['_inheritance'] = $classParams['inheritance']; 201 unset($classParams['inheritance']); 202 } 203 194 204 // Table attributes 195 205 $tableAttributes = array(); … … 248 258 foreach ($this->getChildren($table) as $col_name => $column) 249 259 { 260 // inheritance 261 if (isset($table['_inheritance']) && 262 isset($table['_inheritance']['column']) && 263 $col_name == $table['_inheritance']['column'] && 264 isset($table['_inheritance']['classes']) && 265 is_array($table['_inheritance']['classes'])) 266 { 267 $column['inheritance'] = $table['_inheritance']['classes']; 268 unset($table['_inheritance']); 269 } 270 250 271 $xml .= " <column name=\"$col_name\"".$this->getAttributesForColumn($tb_name, $col_name, $column); 251 272 } … … 524 545 foreach ($column as $key => $value) 525 546 { 526 if (!in_array($key, array('foreignClass', 'foreignTable', 'foreignReference', 'onDelete', 'onUpdate', 'index', 'unique', 'sequence' )))547 if (!in_array($key, array('foreignClass', 'foreignTable', 'foreignReference', 'onDelete', 'onUpdate', 'index', 'unique', 'sequence', 'inheritance'))) 527 548 { 528 549 $attributes_string .= " $key=\"".htmlspecialchars($this->getCorrectValueFor($key, $value), ENT_QUOTES, sfConfig::get('sf_charset'))."\""; 529 550 } 530 551 } 531 $attributes_string .= " />\n"; 552 if (isset($column['inheritance'])) 553 { 554 $attributes_string .= ' inheritance="single">'."\n"; 555 556 $extended_package = isset($this->database[$tb_name]['_attributes']['package']) ? 557 $this->database[$tb_name]['_attributes']['package'] : 558 $this->database['_attributes']['package']; 559 $extended_class = $this->database[$tb_name]['_attributes']['phpName']; 560 561 foreach ($column['inheritance'] as $key => $class) 562 { 563 $attributes_string .= sprintf(' <inheritance extends="%s.%s" key="%s" class="%s" />%s', 564 $extended_package, $extended_class, $key, $class, "\n"); 565 } 566 $attributes_string .= ' </column>'."\n"; 567 } 568 else 569 { 570 $attributes_string .= " />\n"; 571 } 532 572 } 533 573 else branches/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/new_schema.yml
r7394 r8815 11 11 id: 12 12 name: varchar(50) 13 type: varchar(50) 14 inheritance: 15 column: type 16 classes: 17 tight: Group_Tight 18 loose: Group_Loose 13 19 14 20 User: branches/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.xml
r7394 r8815 5 5 <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> 6 6 <column name="name" type="varchar" size="50" /> 7 <column name="type" type="varchar" size="50" inheritance="single"> 8 <inheritance extends="foo.bar.lib.model.Group" key="tight" class="Group_Tight" /> 9 <inheritance extends="foo.bar.lib.model.Group" key="loose" class="Group_Loose" /> 10 </column> 7 11 </table> 8 12 branches/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.yml
r7394 r8815 5 5 id: 6 6 name: varchar(50) 7 type: varchar(50) 8 _inheritance: 9 column: type 10 classes: 11 tight: Group_Tight 12 loose: Group_Loose 7 13 8 14 cd_user: branches/1.1/lib/plugins/sfPropelPlugin/test/unit/sfPropelDatabaseSchemaTest.php
r8155 r8815 48 48 require_once(dirname(__FILE__).'/../../../../yaml/sfYaml.class.php'); 49 49 50 $t = new my_lime_test(2 61, new lime_output_color());50 $t = new my_lime_test(277, new lime_output_color()); 51 51 52 52 $t->diag('Classical YAML to XML conversion');