Question. I have a subclassed entity. The class st...
# box-products
r
Question. I have a subclassed entity. The class structure is like so
BaseEntity -> Trade -> Forward
The Trade class has a
postSave()
method defined. When I save a 'Forward' entity the
postSave( )
interception point is firing twice. When saving a subclass entity, Quick will call
.save()
on the Parent as well, causing the double firing. Is this expected behavior? Personally I expected postSave() to fire once on the parent class.
@elpete @sknowlton
s
I don't think I've ever seen that behavior
Though I'm not sure I have any cases of subclasses with different lifecycle entities than their parent
r
Hmm yeah this is a bit of a problem. Im trying to mull over how to fix this. I can implement the interception methods in all the subclass which would override the parent class but this would be a pain, I am also thinking about preventing parent entities from firing events altogether and then leaving it up to the user to call
super.preSave
or something like that
Update. I came up with a simple solution. In my
postSave( )
method I simply check the entity name that the method was called on. Quick will save the entity name in the evenData argument for the interception point.
Copy code
// Parent Entity Trade.cfc
function postSave(event, eventData, buffer, rc, prc){
	if(arguments.eventData.entityName eq 'Trade'){
		//do stuff here	
	}
}