After collaborating on IRC I found the answer on my own question.
It seems that conditions in the belongsTo
condition of a model is only applied to the JOIN
when querying an Order
.
I was trying to filter Party
on specific roles, e.g. Agent
, which is an alias of a Party
with a role as agent. So the association should be conditioned with a role set as agent. Ideally, this would automatically condition any $this->Order->Agent->find()
calls. But unfortunately, this is not possible due to a technical issue which is being addressed in the development of version 3 of CakePHP.
The solution is to have two types of conditions on the association: one for the JOIN
and one for the association itself.
Why one for the JOIN
? E.g. when a Post
belongs to User
, but only post.validated
should be displayed.