#1208: ability to define record level handlers for custom fields
--------------------------+------------------------------------------------ -
Reporter: ccunningham | Owner: romanb
Type: defect | Status: reopened
Priority: minor | Milestone: 1.0.0-BETA1
Component: Listeners | Version: 0.11
Resolution: | Keywords:
Has_test: 0 | Mystatus: Pending Core Response
Has_patch: 0 |
--------------------------+------------------------------------------------ -
Changes (by ccunningham):
* status: closed => reopened
* resolution: invalid =>
Comment:
Yes, it can be done, however it's a real pain.
I have a number of classes I want to do this on. I have a few entity
classes representing people, I have some other classes which need a piece
of data for 'name' where it's based on whether a custom name has been
chosen, etc. It can be done through the listener interface, however that
would involve having one listener class with a big switch statement ( to
perform the desired custom field for each model type ) or create a bunch
of different listener classes and assign them on a per table basis.
Essentially I either have one big ugly global listener that isn't needed
on all objects, or a bunch of small simple ones I have to attach on each
model type.
While that does do what I want, it isn't convenient or simple...
Why can't I just put a postHydrate() function in each model class and do
what I want there? It would greatly simplify the process and let you keep
these little snippets nicely nested in their own models, so instead of
having all these listener classes laying around I have a nice clean model.
--
Ticket URL: <http://trac.phpdoctrine.org/ticket/1208#comment:3>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper