I am currently developing a Lithium application which requires various things to be added to an object before save() is called.
Ideally I would be able to write a filter to apply to the Model class (the base model that other models extends) such as the following:
Model::applyFilter('save', function($self, $params, $chain) {
// Logic here
});
Is this possible? If so should it be a bootstrapped file?
If I’m not misunderstanding what you’re saying, you want to, for example, automatically add a value for ‘created’ or ‘modified’ to an object before save.
Here’s how I do that.
From my
extensions/data/Model.phpI have some password hashing there as well. You can remove that without affecting any functionality.