Development

Changeset 5578

You must first sign up to be able to contribute.

Changeset 5578

Show
Ignore:
Timestamp:
10/18/07 09:54:16 (1 year ago)
Author:
francois
Message:

sfPropelAlternativeSchemaPlugin Added support for behaviors in the old syntax, and released 1.0 stable

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelAlternativeSchemaPlugin/README

    r5564 r5578  
    259259classes: 
    260260  Article: 
     261    columns: 
     262      title:          varchar(50) 
    261263    behaviors: 
    262       paranoid: { column: deleted_at } 
     264      paranoid:       { column: deleted_at } 
    263265}}} 
    264266 
    265267Of course, don't forget to rebuild the model after you modify your schema. 
     268 
     269It is also possible to define behaviors in the current syntax if you enabled the custom builder in the `propel.ini`. Just add a leading underscore before the `behaviors` key and define behaviors the same a above: 
     270 
     271{{{ 
     272propel: 
     273  ij_article: 
     274    _attributes:    { phpName: Article } 
     275    title:          varchar(50) 
     276    _behaviors: 
     277      paranoid:     { column: deleted_at } 
     278}}} 
     279 
    266280 
    267281Note: Incidentally, behaviors entered this way are registered both in the model and peer classes, which seems to solve some problems with behaviors (like #1229). 
     
    379393=== Trunk === 
    380394 
     395 * francois: Added support for behaviors in the old syntax, too 
    381396 * francois: Added new/old YAML syntax conversion. It is now possible to customize an old schema even if it doesn't use the alternative syntax. 
    382397 * francois: Added a fix for the too late initialization of behaviors in symfony when adding hooks to custom class 
  • plugins/sfPropelAlternativeSchemaPlugin/lib/sfPropelDatabaseSchema.class.php

    r5565 r5578  
    142142          switch($column) 
    143143          { 
     144            case '_behaviors': 
     145              $classes[$phpName]['behaviors'] = $column_params; 
     146              break; 
    144147            case '_foreignKeys': 
    145148              $classes[$phpName]['foreignKeys'] = $column_params; 
     
    210213        } 
    211214         
     215        // Behaviors 
     216        if(isset($classParams['behaviors'])) 
     217        { 
     218          $tableParams['_behaviors'] = $classParams['behaviors']; 
     219          unset($classParams['behaviors']); 
     220        } 
     221         
    212222        // Table attributes 
    213223        $tableAttributes = array(); 
    214          
    215         // Behaviors 
    216         if(isset($classParams['behaviors'])) 
    217         { 
    218           $tableAttributes['behaviors'] = serialize($classParams['behaviors']); 
    219           unset($classParams['behaviors']); 
    220         } 
    221          
    222224        if(isset($classParams['tableName'])) 
    223225        { 
     
    264266    foreach ($this->getChildren($this->database) as $tb_name => $table) 
    265267    { 
    266       $xml .= "\n  <table name=\"$tb_name\"".$this->getAttributesFor($table).">\n"; 
     268      $xml .= "\n  <table name=\"$tb_name\"".$this->getAttributesFor($table); 
     269      if (isset($table['_behaviors'])) 
     270      { 
     271        $xml .= sprintf(" behaviors=\"%s\"", htmlspecialchars(serialize($table['_behaviors']))); 
     272      } 
     273      $xml .= ">\n"; 
    267274 
    268275      // columns 
  • plugins/sfPropelAlternativeSchemaPlugin/package.xml

    r5561 r5578  
    1414  <active>yes</active> 
    1515 </lead> 
    16  <date>2007-10-05</date> 
     16 <date>2007-10-18</date> 
    1717 <version> 
    18    <release>0.9.0</release> 
    19    <api>0.9.0</api> 
     18   <release>1.0.0</release> 
     19   <api>1.0.0</api> 
    2020 </version> 
    2121 <stability> 
    22   <release>beta</release> 
    23   <api>beta</api> 
     22  <release>stable</release> 
     23  <api>stable</api> 
    2424 </stability> 
    2525 <license uri="http://www.symfony-project.com/license">MIT license</license> 
  • plugins/sfPropelAlternativeSchemaPlugin/test/unit/fixtures/new_schema.yml

    r5565 r5578  
    5555    uniques: 
    5656      my_other_index: [created_at] 
     57    behaviors: 
     58      paranoid: { column: deleted_at } 
     59      act_as_nested_set: 
     60       
    5761   
    5862  AbGroupI18n: 
  • plugins/sfPropelAlternativeSchemaPlugin/test/unit/fixtures/schema.xml

    r5519 r5578  
    5454  </table> 
    5555 
    56   <table name="ij_article" phpName="Article"
     56  <table name="ij_article" phpName="Article" behaviors="a:2:{s:8:&quot;paranoid&quot;;a:1:{s:6:&quot;column&quot;;s:10:&quot;deleted_at&quot;;}s:17:&quot;act_as_nested_set&quot;;N;}"
    5757    <column name="title" type="varchar" size="50" /> 
    5858    <column name="user_id" type="integer" /> 
  • plugins/sfPropelAlternativeSchemaPlugin/test/unit/fixtures/schema.yml

    r5519 r5578  
    4141    _uniques: 
    4242      my_other_index: [created_at] 
     43    _behaviors: 
     44      paranoid: { column: deleted_at } 
     45      act_as_nested_set: 
    4346   
    4447  ab_group_i18n: 
  • plugins/sfPropelAlternativeSchemaPlugin/test/unit/sfPropelDatabaseSchemaTest.php

    r5565 r5578  
    4949} 
    5050 
    51 $t = new my_lime_test(257, new lime_output_color()); 
     51$t = new my_lime_test(261, new lime_output_color()); 
    5252 
    5353require_once(dirname(__FILE__).'/../../lib/sfPropelDatabaseSchema.class.php');