#2056: [PATCH] afterFind and beforeFind methods should be called on associated
models
----------------------------+-----------------------------------------------
    Reporter:  maular       |         Owner:                
        Type:  Enhancement  |        Status:  new           
    Priority:  Medium       |     Milestone:  1.3.x.x       
   Component:  Model        |       Version:                
    Severity:  Trivial      |    Resolution:                
    Keywords:               |   Php_version:  PHP 4 >= 4.3.0
Cake_version:  4451         |  
----------------------------+-----------------------------------------------
Comment (by ionas82):

 A tip for those trying to get around this implementation restriction:

 For instance if you have Post HasMany Comment and Comment BelongsTo Post
 and you have a Post with id 1 and that has 3 Commments.

 /posts/view/1 will show you 3 Comments. To modify or remove those Comments
 beforeFilter will not work (nor will afterFilter in means of direct
 manipulation of QUERY you will see with debug = 2 in core.php - the SELECT
 QUERY that will get you the Comments data).

 What will work is to manipulate $results/$data in afterFind() of your
 primary Model (or behavior of that Model). You will have to play around
 with Set:: and array_* of php but it generally works:

 a.) _*without*_ changing dbo_source.php's "function read(..." (to enable
 associated model's beforeFind) or dbo_source.php's "function
 __filterResults()..." (to enable associated model's afterFind)

 b.) because of a.) it "should" not break current CORE behavior's (like
 translate or others I do not know of)

 Happy baking and happy spicing up your /app ;)

  ionas82

 p.s Thanks to Chaso for replying to my question and pointing me towards
 the solution I already had (in another circumstance) in my concrete
 implementation.

-- 
Ticket URL: <https://trac.cakephp.org/ticket/2056#comment:14>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to 
tickets-cakephp+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to