I'm having an issue with a misbehaving behavior. The short of it is that I am hooking into the beforeSave and afterSave callbacks using a behavior, but this has unintended consequences for my situation. Is it possible to replicate this?
$this->Model->bsCallback();
if ($this->Model->saveAll($this->data)) { // Model might have other related models
$this->Model->asCallback();
}
Note that asCallback() would run after saving Model and all related models. That's been my stumbling block, my afterSave in my behavior that is attached to my Model is being called too early and not obtaining data from the related models (because it hasn't been written yet). Putting helper in the model related to Model helps, but I can't be guarantee that the related model would be touched on save, or if it was that all of the models related to Model will have updated by that time.
So yeah, how do I do 'beforeSave' and 'afterSave' correctly on a save that touches multiple models?