Development

Changeset 5561

You must first sign up to be able to contribute.

Changeset 5561

Show
Ignore:
Timestamp:
10/17/07 12:00:38 (1 year ago)
Author:
francois
Message:

sfPropelAlternativeSchemaPlugin Improved behaviors implementation (now with less clutter in config/ folder)

Files:

Legend:

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

    r5548 r5561  
    33== Overview == 
    44 
    5 This plugin extends the symfony model generator, based on Propel, to allow a schema to override another one. It also provides a new YAML syntax for defining database schemas, more explicit and more readable. This new syntax is completely backward compatible with symfony's current `schema.yml` syntax, so installing this plugin will not break your applications. 
     5This plugin extends the symfony model generator, based on Propel, to allow a schema to override another one. It also provides a new YAML syntax for defining database schemas, more explicit and more readable. This new syntax is completely backward compatible with symfony's current `schema.yml` syntax, so installing this plugin will not break your applications. Additionally, the new syntax adds a few new features to schemas, such as the ability to define a behavior from a schema. 
    66 
    77== Installation == 
     
    154154== Behaviors == 
    155155 
    156 The new schema syntax alows you to define behaviors directly from the schema itself. To allow the support for these schema behaviors, you must add this line at the end of all your application's `config.php`: 
    157  
    158 {{{ 
    159 // In apps/myapp/config/config.php 
    160 sfPropelAlternativeSchema::initializeBehaviors(); 
     156The new schema syntax alows you to define behaviors directly from the schema itself. To allow the support for these schema behaviors, you must change two lines in the 'Builder Settings' section of your project's `propel.ini`: 
     157 
     158{{{ 
     159// In config/propel.ini 
     160; builder settings 
     161propel.builder.peer.class              = plugins.sfPropelAlternativeSchemaPlugin.lib.SfAlternativePeerBuilder 
     162propel.builder.object.class            = plugins.sfPropelAlternativeSchemaPlugin.lib.SfAlternativeObjectBuilder 
    161163}}} 
    162164 
     
    172174Of course, don't forget to rebuild the model after you modify your schema. 
    173175 
    174 This feature groups the behaviors declarations into a single file called `behaviors.php`, located under the `cache/` directory, for maximum efficiency. This file will be regenerated during the first request after each model rebuild. 
    175  
    176 Note that this feature will also add `.behaviors` files under your project's `config/` directory. These are generated by the `propel-build-model` task and should not be deleted, otherwise the behaviors will not work when you transfer the project to another host and clear the cache manually. 
     176Note: Incidentally, behaviors entered this way are registered both in the model and peer classes, which seems to solve some problems with behaviors (like #1229). 
    177177 
    178178== Customizing an existing schema == 
     
    293293=== Trunk === 
    294294 
     295 * francois: Added a fix for the too late initialization of behaviors in symfony when adding hooks to custom class 
    295296 * francois: Added a way to define behaviors from the schema 
    296297 * francois: Added a new `foreignClass` column attribute to define a foreign key from a phpName rather than from a tableName 
  • plugins/sfPropelAlternativeSchemaPlugin/lib/sfPropelDatabaseSchema.class.php

    r5548 r5561  
    9191  public function loadNewYaml($schema) 
    9292  { 
    93     sfPropelAlternativeSchema::cleanBehaviorsOnce(); 
    9493     
    9594    if(isset($schema['connection'])) 
     
    137136        } 
    138137         
     138        // Table attributes 
     139        $tableAttributes = array(); 
     140         
    139141        // Behaviors 
    140142        if(isset($classParams['behaviors'])) 
    141143        { 
    142           sfPropelAlternativeSchema::addBehaviors($className, $classParams['behaviors']); 
     144          $tableAttributes['behaviors'] = serialize($classParams['behaviors']); 
    143145          unset($classParams['behaviors']); 
    144         }         
     146        } 
    145147         
    146         // Table attributes 
    147         $tableAttributes = array(); 
    148148        if(isset($classParams['tableName'])) 
    149149        { 
  • plugins/sfPropelAlternativeSchemaPlugin/package.xml

    r5548 r5561  
    3232     <dir name="lib"> 
    3333       <file role="data" name="sfPropelDatabaseSchema.class.php" /> 
    34        <file role="data" name="sfPropelAlternativeSchema.class.php" /> 
     34       <file role="data" name="SfAlternativeObjectBuilder.php" /> 
     35       <file role="data" name="SfAlternativePeerBuilder.php" /> 
    3536     </dir> 
    3637