Development

Changeset 8815

You must first sign up to be able to contribute.

Changeset 8815

Show
Ignore:
Timestamp:
05/06/08 19:59:18 (5 months ago)
Author:
FabianLange
Message:

added support for propels inheritance model to symfony 1.1 propel 1.2 plugin.
Thanks to Kris.Wallsmith for that contribution. Refs #3473

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/sfPropelDatabaseSchema.class.php

    r7928 r8815  
    117117              $classes[$phpName]['behaviors'] = $column_params; 
    118118              break; 
     119            case '_inheritance': 
     120              $classes[$phpName]['inheritance'] = $column_params; 
     121              break; 
    119122            case '_foreignKeys': 
    120123              $classes[$phpName]['foreignKeys'] = $column_params; 
     
    192195        } 
    193196         
     197        // Inheritance 
     198        if (isset($classParams['inheritance'])) 
     199        { 
     200          $tableParams['_inheritance'] = $classParams['inheritance']; 
     201          unset($classParams['inheritance']); 
     202        } 
     203         
    194204        // Table attributes 
    195205        $tableAttributes = array(); 
     
    248258      foreach ($this->getChildren($table) as $col_name => $column) 
    249259      { 
     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         
    250271        $xml .= "    <column name=\"$col_name\"".$this->getAttributesForColumn($tb_name, $col_name, $column); 
    251272      } 
     
    524545      foreach ($column as $key => $value) 
    525546      { 
    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'))) 
    527548        { 
    528549          $attributes_string .= " $key=\"".htmlspecialchars($this->getCorrectValueFor($key, $value), ENT_QUOTES, sfConfig::get('sf_charset'))."\""; 
    529550        } 
    530551      } 
    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      } 
    532572    } 
    533573    else 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/new_schema.yml

    r7394 r8815  
    1111      id: 
    1212      name:           varchar(50) 
     13      type:           varchar(50) 
     14    inheritance: 
     15      column:         type 
     16      classes: 
     17        tight:        Group_Tight 
     18        loose:        Group_Loose 
    1319   
    1420  User: 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.xml

    r7394 r8815  
    55    <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> 
    66    <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> 
    711  </table> 
    812 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/unit/fixtures/schema.yml

    r7394 r8815  
    55    id: 
    66    name:           varchar(50) 
     7    type:           varchar(50) 
     8    _inheritance: 
     9      column:       type 
     10      classes: 
     11        tight:      Group_Tight 
     12        loose:      Group_Loose 
    713     
    814  cd_user: 
  • branches/1.1/lib/plugins/sfPropelPlugin/test/unit/sfPropelDatabaseSchemaTest.php

    r8155 r8815  
    4848require_once(dirname(__FILE__).'/../../../../yaml/sfYaml.class.php'); 
    4949 
    50 $t = new my_lime_test(261, new lime_output_color()); 
     50$t = new my_lime_test(277, new lime_output_color()); 
    5151 
    5252$t->diag('Classical YAML to XML conversion');