Reputation: 1812
I log changes for objects in my application within the processForm function by checking for differences in the object before and after its been saved. I persist that to a log table in my database.
For the sfGuardUser backend, I use the generated admin, which automatically saves changes made to the embedded groups or permissions.
I'd like to log those changes - but where can I add my log process?
Upvotes: 0
Views: 333
Reputation: 22756
Well I think the best place to handle such change is in the model instead of in the processForm. This is the perfect job of a behavior.
There is a behavior called versionable which do exactly what you did: historize each change on a model and you just have to define it in your schema.yml:
BlogPost:
_propel_behaviors:
versionable:
log_created_at: true
log_created_by: true
log_comment: true
columns:
title: string(255)
body: clob
So maybe you can get inspiration from this behavior to create your own. And then you just to modify the schema.yml of sfGuard, like:
sfGuardGroupPermission:
_attributes: { phpName: sfGuardGroupPermission }
_propel_behaviors:
versionable: { log_created_at: true, log_created_by: true, log_comment: true }
Edit: Switched to Propel.
Upvotes: 1