Archive for June 6th, 2009

Doctrine Behaviours

I’m finding that I need to write a couple behaviors that for some reason are not in the default distribution.  The features I’m needing in particular are “Signable” to add created_by, updated_by and deleted_by to each table, and “Commentable” to handle the comments that you’re going to be able to post on almost every single object.

Thankfully the best way for me to learn is to find an example.  I’m going to modify the code for “Timestampable” for “Signable” and I think I’m going to look at csDoctrineActAsAttachablePlugin for how it behaves and build from it to make “Commentable”.  I might even release it to the community.

Doctrine Behaviours are fairly new to me but I understand what’s going on for sure.  Behaviours allow you to modularize your reusable database code.  In my examples, I need to be able to keep track of who created, updated, and/or deleted an item.  Instead of adding that bit of code to each model by hand, I can cut it out and make a Behaviour that I then attach to each model.

, , , ,

No Comments