Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Behavior afterFind on associated Model
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joshua Benner  
View profile  
 More options Jun 11 2007, 3:25 pm
From: Joshua Benner <joshben...@gmail.com>
Date: Mon, 11 Jun 2007 15:25:42 -0400
Local: Mon, Jun 11 2007 3:25 pm
Subject: Behavior afterFind on associated Model
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 Benner
http://bennerweb.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zaboo  
View profile  
 More options Jul 10 2007, 10:43 am
From: zaboo <adambartholo...@gmail.com>
Date: Tue, 10 Jul 2007 07:43:05 -0700
Local: Tues, Jul 10 2007 10:43 am
Subject: Re: Behavior afterFind on associated Model
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 <joshben...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Hartjes  
View profile  
(1 user)  More options Jul 10 2007, 11:10 am
From: "Chris Hartjes" <chart...@gmail.com>
Date: Tue, 10 Jul 2007 11:10:58 -0400
Local: Tues, Jul 10 2007 11:10 am
Subject: Re: Behavior afterFind on associated Model
On 7/10/07, zaboo <adambartholo...@gmail.com> wrote:

> 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.

zaboo,

You should submit that patch via trac.cakephp.org as 99.999% of patch
code that shows up in the mailing list is ignored.  This goes for
anyone else who has a patch.  I can say with 100% certainty that every
patch that is submitted is looked at and considered.

--
Chris Hartjes
Senior Developer
Cake Development Corporation

My motto for 2007:  "Just build it, damnit!"

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Grant Cox  
View profile  
 More options Jul 10 2007, 12:17 pm
From: Grant Cox <grant....@gmail.com>
Date: Tue, 10 Jul 2007 09:17:16 -0700
Local: Tues, Jul 10 2007 12:17 pm
Subject: Re: Behavior afterFind on associated Model
    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google