cakephp/cakephp — pull request #2794 by lorenzo (2014-02-09 12:15:40+00:00)
Title: 3.0 - Trigger beforeFind for associations

This set of changes closes the long standing CakePHP issue of association callbacks not being triggered. I'm sorry for the long diff, but the problem turned out to be way more complex that I originally thought. In hindsight I totally understand why it was impossible to implement such a thing in 2.x.

### Changes sumary:

* `Model.beforeFind` is triggered for both "attachable" and external associations, that is, associations that are joined or selected in a separate query.
* `beforeFind` is allowed to add more contains to the original query. In fact, the query passed to associations' beforeFind is a dummy query, all important stuff is then copied to the main query. This is so, because calling methods directly on the main query makes it more difficult to re-arrange values such as formatters and contain.
* Added `Collection::insert()`. It allows you to merge two separate collection by inserting all the elements from one into a property in each of the elements of another.
* `beforeFind` is allowed to add formatters to the original query. Since the formatters are intended only for the associated records, used `Collection::insert()` jail the iterator and only pass the correct properties.
* Added integration test in `TranslateBehavior` to showcase how loading extra associations and formatters can be used effectively from a `beforeFind`