Joshua,
Little late on this topic but yes, you are correct. Even as of the
latest 1.2.0.5427alpha (July 9, 2007) Behavoir::afterFind is not
called for deep associations. I ran into a similar problem so I have
just modified the core CAKE/libs/model/datasources/dbo_source.php to
do so. I know this is not ideal for upgrades, but hey - it works.
~Line 787: $resultSet[$i][$association] = $linkModel-
>afterfind($resultSet[$i][$association]);
Added:
foreach($linkModel->behaviors as
$behavior) {
if(method_exists($behavior,
'afterfind') && $filtered_data =
$behavior->afterFind(&$linkModel, $resultSet[$i][$association],
false)) {
$resultSet[$i][$association] = $filtered_data;
}
}
~Line: 670: $data = $model->{$className}-
>afterFind(array(array($key => $results[$i][$key])), false);
Added:
foreach($model->{$className}->behaviors as $behavior) {
if(method_exists($behavior, 'afterfind') && $filtered_data =
$behavior->afterFind(&$model->{$className}, $data, false)) {
$data =
$filtered_data;
}
}
Hope this helps someone..
Cheers!
On Jun 11, 3:25 pm, Joshua Benner <[EMAIL PROTECTED]> wrote:
> ModelA hasMany ModelB
> ModelB actsAs SomeBehavior
>
> SomeBehavior defines afterFind()
>
> ModelAController::someAction() has:
> $this->ModelA->recursive = 1;
> $this->ModelA->findAll();
>
> Will SomeBehavior::afterFind() be triggered for ModelB, since ModelB
> will be retrieved via association to ModelA?
>
> So far in my testing, the afterFind on the behavior does not seem to be
> called. Is this normal? Is this on purpose?
>
> The $primary argument in behavior functions would seem to suggest that
> the behavior functions should still be called even if the model acting
> as the behavior is being queried as a result of an association.
>
> I may be confused on this, though. Any help?
>
> --
> Joshua Bennerhttp://bennerweb.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---