Changeset 5548
- Timestamp:
- 10/16/07 18:23:23 (1 year ago)
- Files:
-
- plugins/sfPropelAlternativeSchemaPlugin/README (modified) (4 diffs)
- plugins/sfPropelAlternativeSchemaPlugin/lib/sfPropelAlternativeSchema.class.php (added)
- plugins/sfPropelAlternativeSchemaPlugin/lib/sfPropelDatabaseSchema.class.php (modified) (3 diffs)
- plugins/sfPropelAlternativeSchemaPlugin/package.xml (modified) (1 diff)
- plugins/sfPropelAlternativeSchemaPlugin/test/unit/sfPropelDatabaseSchemaTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelAlternativeSchemaPlugin/README
r5519 r5548 152 152 }}} 153 153 154 == Behaviors == 155 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(); 161 }}} 162 163 Now you can add a `behaviors` section for each class that you define in a schema, as follows: 164 165 {{{ 166 classes: 167 Article: 168 behaviors: 169 paranoid: { column: deleted_at } 170 }}} 171 172 Of course, don't forget to rebuild the model after you modify your schema. 173 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. 177 154 178 == Customizing an existing schema == 155 179 … … 201 225 tableName: ab_group 202 226 package: foo.bar.lib.model 227 behaviors: [paranoid] 203 228 columns: 204 229 id: … … 223 248 tableName: ab_group 224 249 package: foo.bar.lib.model 250 behaviors: [paranoid] 225 251 columns: 226 252 id: … … 263 289 }}} 264 290 265 == TODO ==266 267 * Manage behaviors directly in the schema268 269 291 == Changelog == 270 292 271 293 === Trunk === 272 294 295 * francois: Added a way to define behaviors from the schema 273 296 * francois: Added a new `foreignClass` column attribute to define a foreign key from a phpName rather than from a tableName 274 297 * francois: Added section about plugin check in README plugins/sfPropelAlternativeSchemaPlugin/lib/sfPropelDatabaseSchema.class.php
r5519 r5548 91 91 public function loadNewYaml($schema) 92 92 { 93 sfPropelAlternativeSchema::cleanBehaviorsOnce(); 94 93 95 if(isset($schema['connection'])) 94 96 { … … 135 137 } 136 138 139 // Behaviors 140 if(isset($classParams['behaviors'])) 141 { 142 sfPropelAlternativeSchema::addBehaviors($className, $classParams['behaviors']); 143 unset($classParams['behaviors']); 144 } 145 137 146 // Table attributes 138 147 $tableAttributes = array(); … … 254 263 } 255 264 } 256 265 257 266 $xml .= " </table>\n"; 258 267 } plugins/sfPropelAlternativeSchemaPlugin/package.xml
r5415 r5548 32 32 <dir name="lib"> 33 33 <file role="data" name="sfPropelDatabaseSchema.class.php" /> 34 <file role="data" name="sfPropelAlternativeSchema.class.php" /> 34 35 </dir> 35 36 plugins/sfPropelAlternativeSchemaPlugin/test/unit/sfPropelDatabaseSchemaTest.php
r5519 r5548 10 10 11 11 include(dirname(__FILE__).'/../../../../test/bootstrap/unit.php'); 12 13 class sfPropelAlternativeSchema 14 { 15 static function cleanBehaviorsOnce() 16 { 17 18 } 19 } 12 20 13 21 class my_lime_test extends lime_test